Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore Beginning Arduino

Beginning Arduino

Published by Rotary International D2420, 2021-03-23 12:47:19

Description: Michael McRoberts - Beginning Arduino-Apress (2010)

Search

Read the Text Version

■ INDEX PCB (Printed Circuit Board), 4 pointers, 73 peizo sounder alarm, 81–85 Pong game, 164–169 port number, 364 circuit connections, 81 port selection, 8–10 code overview, 83– 84 post() method, 398 hardware overview, 84–85 post-decrement, 73 parts required, 81 potential divider, 95 project code, 82 potentiometers, 54–57, 99, 164, 166 persistence of vision, 135 pgm_read_byte command, 162 for DC motor control, 102 PGMPrint() command, 323 joystick, 202 pgmspace library, 155, 161 Preferences option, 16 photoresistor, 94 pressure sensors, 231–257 Physical or Embedded Computing digital platform, 3 circuit connections, 232–233 piezo disc, 85 code overview, 236–244 piezo knock sensor, 89–92 parts required, 231–232 project code, 233–236 circuit connections, 90 digital barograph code overview, 91–92 circuit connections, 246–247 parts required, 89 code overview, 252–257 project code, 90–91 parts required, 245 piezo sounder, 84 project code, 247–252 piezo sounder melody player, 85–89 print() command, 74, 177 code overview, 86–89 println command, 74 project code, 85–86 printTemperature() function, 290 Pin 13 LED, 12 printTrend() function, 253–256 pinMode, 48 PROGMEM command, 156 pins/pinouts Program Space utilities, 155–156 between Arduino, IC, and dot matrix pull-down resistors, 38, 45–48 pull-up resistors, 47–48 display, 146 pulsating lamp, 58–60 between Mega and the GLCD, 246 circuit connections, 58 changing mode between INPUT and code overview, 60 parts required, 58 OUTPUT, 48 project code, 59–60 for dot matrix display, 131 for L293D, 109 for LCD, 268 for MAX7219, 152 427

■ INDEX circuit connections, 344–345 hardware overview, 345–346 pulse width, 60 parts required, 343 Pulse Width Modulation (PWM), 60 project code, 345 pulseIn command, 296 RGB LEDs, 31, 63, 272 PWM functions, 194 RGB mood lamp, 61–66 circuit connections, 61 ■Q code overview, 63–66 parts required, 61 QUIT command, 390 project code, 61, 63 RGB values, 63–65, 70 ■R RGB2 array, 64 robots random numbers, 64–65 controlling two-wheeled, 213–219 random() function, 64–65 line following, 219 randomSeed command, 64, 167 circuit connections, 220–222 read() command, 195, 326, 382 code overview, 225–229 read_register16() function, 244 parts required, 220 readPot() function, 310–311 project code, 223–225 request_pause, 379 rotate value, 226 resetEthernetShield() function, 378 RSS (Really Simple Syndication), 401 resistance, 28 RSS Weather Reader, 401 resistive touch screens, 262 code overview, 406– 414 resistors, 28–30 project code, 401–405 color codes, 29 ■S pull-down, 38, 45–48 pull-up, 47–48 S.O.S. morse code signaler, 31–34 reverse voltage, 104 code overview, 33– 34 RFID (Radio Frequency Identification) project code, 32–3 readers, 343–357 Save button, 14 access control system scan limit, 155 scope, variable, 34 circuit connections, 348 SCP1000 absolute digital pressure sensor, code overview, 351–356 parts required, 347 231 project code, 348–351 battery assisted passive, 345 passive, 345 simple, 343 428

screenUpdate() function, 137–138, ■ INDEX 143–144, 156, 163 pressure sensor, 231–257 screw terminal, 84 serial temperature sensor, 279–283 scroll() function, 158 serial buffer, 72 scrollDisplayLeft() function, 178, 272 serial clock line (SCL), 339 scrollDisplayRight() function, 178 serial communication, 71–74 scrollLCD() function, 271–272 serial controlled mood lamp, 68–79 SD cards, 317 code overview, 71–79 project code, 69–70 initializing, 337 pseudo-code, 77–79 simple/read write, 317 serial data line (SDA), 339 serial monitor, 15, 70 circuit connections, 318 Serial Monitor button, 15 code overview, 322–327 Serial Peripherals Interface (SPI), 238–240 parts required, 317 Serial Port list, 10 project code, 319–322 serial temperature sensor temperature SD datalogger, 327 circuit connections, 280 circuit connections, 328–329 code overview, 282–283 code overview, 334–339 parts required, 279 hardware overview, 339–340 project code, 280–281 parts required, 327 serial window, 15 project code, 329–334 Serial.available() function, 72 SD/MMC Card Breakout Board, 317 Serial.begin() function, 71 SdFat.h library, 319, 322 Serial.flush() function, 71, 199 SdFatUtil.h library, 319 Serial.print() function, 74, 400 secondChrRow, 159–160 Serial.read() function, 73 Send button, 15 serialEvent() function, 408 sendEmail function, 392 Serialprintln() function, 74 sensor bar, 221–222 SerialPrintln_P command, 323 sensors serial-to-parallel data conversion, 116 1-wire digital temperature sensor, Servo.h library, 191, 194–195, 199 servo1, 194 283–291 servos, 191–206 analog temperature sensor, 279–280 continuous rotation, 195–196 digital pressure sensor, 231–245 Dual Servo Control, 196–201 light sensor, 92–96 Joystick Servo Control, 201–206 piezo knock sensor, 89–92 429

■ INDEX linear actuator, 196 sine waves, 60 position control, 195 single pole, double throw type (SPDT) servo control, 192–196 switch, 299 circuit connections, 193 sinVal float variable, 83 code overview, 194–195 sizeof() function, 88, 378 hardware overview, 195–196 Sketch menu, 18 parts required, 192 Sketch Window, 13 project code, 193 sketches, 4 uses of, 191–192 .set() function, 337 uploading first, 10–12 setCursor() function, 178 SoftwareSerial object, 351 setDigit() function, 305 SoftwareSerial.h library, 351 SetDot () function, 253 SONAR (sound navigation and ranging), setLED() function, 76, 77 .setLed() function, 168 297 .setResolution() function, 290 specifiers, 380 .setRow() function, 169 speed pins, 217 setServo routine, 200 SPI (Serial Peripheral Interface), 231 .setSpeed() function, 210 SPI Control Register, 238, 239 setup() function, 24–26, 101, 163, 167, 324, SPI Status Register (SPSR), 240 SPI.h library, 363 327 spi_transfer() function, 242 setupEthernet() function, 378, 383 splitString() function, 73–76, 200 shields, 5 sprintf command, 379–380, 399–400 shift registers, 111–129 SRAM (Static Random Access memory), 8-bit binary counter, 111–124 156 circuit connections, 111–112 standard value resistors, 28 code overview, 118–124 .start() function, 337 hardware overview, 116–118 startAlarm() function, 311 parts required, 111 step angle, 210 project code, 112–113 Stepper library, 18 stepper motors, 207 daisy-chained, 124–128 shiftIt() function, 139, 144 about, 211 shiftOut() function, 119, 127 basic stepper control Show Sketch Folder option, 18 sin() function, 60 circuit connections, 208–209 code overview, 210–211 hardware overview, 211–213 430

■ INDEX parts required, 207 parts required, 327 project code, 209–210 project code, 329–334 increasing resolution of, 213 temperature sensors, 279–291 object creation, 210 calibrating, 281 setting speed of, 210 digital, 283 step angle, 210 step sequence for, 212 circuit connections, 284 types and sizes, 211 code overview, 289–291 stepper.h library, 210–211 parts required, 283 Stop button, 14–15 project code, 284–289 .stop() command, 337, 367 serial strcmp() function, 356, 410 circuit connections, 280 String Compare function, 356 code overview, 282–283 string data type, 42 parts required, 279 string manipulation, 73–76 project code, 280–281 stripboard, 105 temporary string (tmpStr), 410 strLen() function, 380, 412 Timer1 function, 138 strLength variable, 159 TimerOne library, 132, 137, 141, 156 strncpy command, 410 timestamp command, 325 strstr command, 382 tmpStr (temporary string), 410 strtok command, 75–76 toFahrenheit() function, 290 strtol (String to long integer) command, 77 tone() command, 83 switch/case command, 186–187 toneVal variable, 83 switches, 45 Toolbar, 13–14 Toolbar button functions, 14 ■T Tools menu, 18 touch function, 272 tactile switches, 38, 45 touch screens, 259–278 tag string (tgrStr), 410 basic temperature scales circuit connections, 260–261 code overview, 264–266 converting between, 282, 290 hardware overview, 262–263 temperature SD datalogger, 327 parts required, 259 project code, 261–262 circuit connections, 328–329 light controller, 272 code overview, 334–339 circuit connections, 273–274 hardware overview, 339–340 431

■ INDEX ultrasonic distance display circuit connections, 299–301 code overview, 276–278 code overview, 303–305 parts required, 272–273 parts required, 298–299 project code, 274, 276 project code, 301–303 resistive, 262 touch screen keypad, 266 ultrasonic rangefinder, 293–315 circuit connections, 267–268 simple code overview, 270–272 circuit connections, 293–294 parts required, 266–267 code overview, 295–296 project code, 268, 270 hardware overview, 297 touch() function,264, 277– 278 parts required, 293 traffic lights, 34–37 project code, 294–295 code, 36–37 connections, 35–36 ultrasonic theremin, 312 parts required, 35 code overview, 313–314 transistors, for DC motor control, 99, project code, 312–313 102–103 unipolar motors, 211–212 tri-color LEDs, 31 unlock() function, 356 trimmer potentiometer, 279, 281 Uno board, 4–6 truth tables, 44 unsigned char data type, 42 tweet() function, 400 unsigned int data type, 42 Twitter library, 394, 397 unsigned long data type, 41–42 Twitterbot, 393 Upload to I/O Board button, 15 USB A to Mini-B cable, 6 code overview, 396–401 USB cable, 6 project code, 393–396 USB socket, 4 Two Wire Interface (TWI), 339 User-Agent request-header, 381 two-dimensional arrays, 142–143 ■V ■U variable names, 24 UBLB command, 244 variable scope, 34 ultrasonic alarm variables, 24 circuit connections, 306–307 direction, 54 code overview, 309–312 local scope, 75 parts required, 306 storage of, 42 project code, 307–309 432

Verify/Compile button, 14, 18 ■ INDEX Vin pin, 208 Vista installation, 7 Windows XP installation, 7 void keyword data type, 42 Wire.h library, 334 voltage, 28 word data type, 42 voltage divider, 95 WProgram.h library, 334 write() function, 181, 323 ■W write_register() function, 241 writeCRLF() function, 323 wait() function, 398 writeString() function, 324 while() function, 72, 323 while loop, 73 ■X, Y, Z Windows 7 installation, 7 XML (Extensible Markup Language), 401 XOR (Exclusive OR), 354 433








Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook