ARDUINO FOR BEGINNERS
Smitha Pisupati and Sushma Rao Apr 26 2015
ARDUINO FOR BEGINNERS Smitha Pisupati and Sushma Rao Apr 26 2015 - - PowerPoint PPT Presentation
ARDUINO FOR BEGINNERS Smitha Pisupati and Sushma Rao Apr 26 2015 What is Arduino An open source electronics platform Easy to use HW and SW Make interactive projects No electronics background required The HW Arduino
Smitha Pisupati and Sushma Rao Apr 26 2015
¨ An open source electronics platform ¨ Easy to use HW and SW ¨ Make interactive projects ¨ No electronics background required
Download: http://arduino.cc/en/Main/Software
¨ Connect the Arduino to the PC/Mac ¨ Open the Blink example
¨ Upload!
Hey Arduino, Run this part when you power up! Hey Arduino, Run this part over and over, forever!
Set Pin 13 to
Set Pin 13 to HIGH Set Pin 13 to LOW Wait 1 second Wait 1 second
http://www.crifan.com/arduino_and_bread_board/
Connections in the breadboard Breadboard Internals
¨ Limits amount of charge flowing through the circuit ¨ Has a “resistance” ¨ Higher the resistance,
¨ Circuit diagram ¨ Uses symbols for electronic components
¨ A.K.A The Pot ¨ Variable resistor
¨ Voltage divider ¨ Voltage at A0 is
¨ In the loop function, add the following line:
¨ Change delay(1000) to the following:
¨ Add the following line to the setup() function
¨ Add the following line to the loop() function
¨
More details at http://www.arduino.cc/en/Reference/Serial
¨ 4 pins
¤ VCC ¤ GND ¤ Trigger ¤ Echo
¨
Add the following at the top of the file
unsigned long distanceInCm = 0;
¨
Add the following lines of code in the setup() function
pinMode (trigger, OUTPUT); pinMode(echo, INPUT);
¨
Add the following in the loop() function
// Hold trigger pin high for 10 microseconds digitalWrite(trigger, HIGH); delayMicroseconds(10); digitalWrite(trigger, LOW); // Get the width of the pulse with pulseIn count = pulseIn(echo, HIGH); // get distance in cm. Divide by 148 for inches distanceInCm = count / 58;
¨ Add the following at the top of the file
int ledPin = 13;
¨ Add the following lines of code in the setup() function
pinMode(ledPin, OUTPUT);
¨ Add the following in the loop() function
if(distanceInCm < 10) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }
¨ Add the following at the top of the file
¨ Add the following lines of code in the setup()
¨ Add the following in the loop() function
if(distanceInCm < 10) { digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, HIGH); digitalWrite(ledPin3, HIGH); … } else { digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, LOW); … }
¨ Upload and check that this works…
if(distanceInCm < 10) { digitalWrite(ledPin1, HIGH); … } else if (distanceInCm < 12) { digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, LOW); … } else { digitalWrite(ledPin1, LOW); … }
¨ link to source ¨ Copy the top part of the file that looks like this:
¨ Connect the Piezo buzzer at pin 5 ¨ Add this line to the top of the file
¨ Add this to the setup() function
¨ Add this to the loop() function
¨ http://www.arduino.cc/en/Reference/Tone ¨ http://www.arduino.cc/en/Tutorial/HomePage