1 / 11

switches & whiskers on the Arduino

living with the lab. switches & whiskers on the Arduino. lever arm switches mounted to Arduino. © 2012 David Hall. living with the lab. The content of this presentation is for informational purposes only and is intended only for students attending Louisiana Tech University.

gerry
Download Presentation

switches & whiskers on the Arduino

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. living with the lab switches & whiskers on the Arduino lever arm switches mounted to Arduino © 2012 David Hall

  2. living with the lab The content of this presentation is for informational purposes only and is intended only for students attending Louisiana Tech University. The author of this information does not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in injury or damage. Louisiana Tech University and the State of Louisiana, their officers, employees, agents or volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. If you do not agree, then do not view this content. The copyright label, the Louisiana Tech logo, and the “living with the lab” identifier should not be removed from this presentation. You may modify this work for your own purposes as long as attribution is clearly provided. DISCLAIMER & USAGE

  3. living with the lab the switches • long lever with three electrical terminals • can be wired as normally open (electricity flows only when switch pressed) • can be wired as normally closed (electricity stops flowing when switch pressed) • used with 0.183 inch quick disconnect terminals

  4. living with the lab wiring when the switch is not pressed, electricity can pass through the normally closed (NC) path when the switch ispressed, electricity can pass through the normally open (NO) path

  5. living with the lab use a digital input to sense when switch is on or off check status of pin 7 using . . . digitalRead(7) 10kW switch 3 2 1 0 9 8 7 6 5 4 3 2 1 0 AREF GND 1 1 1 1 DIGITAL Arduino ANALOG POWER RESET 3V3 5V Gnd Vin 0 1 2 3 4 5 0V (no power applied) open (not pressed) LOW 5V (direct connection to power) closed (pressed) HIGH

  6. living with the lab why the 10kΩ resistor? using a large resistance limits the current so that we don’t waste electricity 10kW switch 3 2 1 0 9 8 7 6 5 4 3 2 1 0 AREF GND 1 1 1 1 DIGITAL Arduino ANALOG POWER RESET 3V3 5V Gnd Vin 0 1 2 3 4 5 . . . any resistor will do, but there’s no sense in wasting power

  7. living with the lab hooking things up on your robot • space is tight, and it’s easy to break the quick disconnect terminals (can solder them if desired) • connect wires to the common and normally open terminals on the switch

  8. living with the lab tools a wire stripper and some sort of crimping tool are needed (can also crudely crimp using a vise)

  9. living with the lab completing the circuit on the breadboard white and red leads provide digital input one 10kΩ resistor per switch is installed violet leads go to +5V source try to keep the wiring tidy . . . • to prevent wires from coming loose • to make it easier to see what’s going on (easier to troubleshoot)

  10. living with the lab programming this program causes the built-in LED on pin 13 to turn on when the switch is pressed int whisker1=0; void setup(){pinMode(7,INPUT);pinMode(13,OUTPUT);} void loop(){ whisker1=digitalRead(7); if(whisker1== HIGH) // whisker1==HIGH if whisker pressed { digitalWrite(13,HIGH); } // turn LED on pin13 on else { digitalWrite(13,LOW); } // turn LED on pin13 off} this is our first time to use if … else control (see next slide)

  11. living with the lab if / else if/else allows greater control over the flow of code than the basic if statement, by allowing multiple tests to be grouped together arduino.cc if(x < 500) { // do Thing A } else if(x >= 1000) { // do Thing B } else { // do Thing C } can use an unlimited number of else if blocks . . . or none, as in the program on the previous slide

More Related