Download presentation
Presentation is loading. Please wait.
Published byJulian Bishop Modified over 6 years ago
1
CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno
2
http://forum. arduino. cc/index. php/topic,146315. html http://forum
3
Pull-up vs pull-down switch interface
Pull up switch circuit Pull down switch circuit
4
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);
5
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
6
References http://www.gammon.com.au/uno
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.