CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno https://store.arduino.cc/usa/arduino-uno-rev3
http://forum. arduino. cc/index. php/topic,146315. html http://forum http://forum.arduino.cc/index.php/topic,146315.0.html http://forum.arduino.cc/index.php?action=dlattach;topic=146315.0;attach=90365
Pull-up vs pull-down switch interface Pull up switch circuit Pull down switch circuit
Connecting a switch to an I/O pin LED connected same as before (pin 8 in this example) Add the switch circuit (pin 4 in this example) //sample switch code const int buttonPin = 4; const int ledPin = 8; int buttonState = 0; void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW);
Lab assignment There are only 29 kits which means each group needs to have 3.2 members per team Get the onboard LED to light when the switch is held down Get the LED to toggle with the switch – push on -> push off -> etc. Mouse button – single click -> red LED, double click -> green LED, long press -> all off. Play
References http://www.gammon.com.au/uno https://itp.nyu.edu/physcomp/lessons/microcontrollers/microcontroller-pin-functions/ http://forum.arduino.cc/index.php/topic,146315.0.html https://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/ https://store.arduino.cc/usa/arduino-uno-rev3 http://www.electricrcaircraftguy.com/2014/02/arduino-power-current-and-voltage.html https://www.arduino.cc/en/Main/Software http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/ https://liudr.wordpress.com/2011/10/16/sourcing-and-sinking-current/