cs120 fall 2019 lab 9 – week of november 17th arduino time

1
CS120 Fall 2019 Lab 9 – Week of November 17th ARDUINO TIME Just a little bit of fun with the Arduino. It’s just wires and electricity. Don’t let it freak you out! 1) Open “file/examples/basics/blink” – this is a small sample program. 2) Click the “upload” button – this is an arrow to the right 3) If everything is set up correctly, you’ll see the LEDs on the Arduino flicker for a moment, and then there will be a single LED that blinks on and off. The TA has breadboards, LEDs, wires, and resistors. On the breadboard, the long vertical stripes on the left and right (with the blue and red) are connected – they are normally used for power and ground. In the middle, the left horizontal group of five holes are connected, as are the right. An LED will light up when the longer leg has power (5 volts), and the shorter leg is connected to ground (abbreviated GND). To keep the LED from using too much power, connect the negative pin of the LED to ground using a 1k ohm resistor (stripes are brown/black/red). Try connecting up an LED to power and ground from the Arduino – make sure it turns on. Then, connect it to pin 13 on the board – it should blink in the same way as the LED embedded on the Arduino. And now… Move it to connect to pin 12, and have them alternate on and off…. Add some more LEDs, using other pins from the Arduino. Can you bounce the lights back and forth? Get them to count? Once you’ve got that going…. There are some speakers. Check out the ToneMelody sketch.

Upload: others

Post on 08-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS120 Fall 2019 Lab 9 – Week of November 17th ARDUINO TIME

CS120Fall2019Lab9–WeekofNovember17thARDUINOTIME

JustalittlebitoffunwiththeArduino.It’sjustwiresandelectricity.Don’tletitfreakyouout!1)Open“file/examples/basics/blink”–thisisasmallsampleprogram.2)Clickthe“upload”button–thisisanarrowtotheright3)Ifeverythingissetupcorrectly,you’llseetheLEDsontheArduinoflickerforamoment,andthentherewillbeasingleLEDthatblinksonandoff.TheTAhasbreadboards,LEDs,wires,andresistors.

Onthebreadboard,thelongverticalstripesontheleftandright(withtheblueandred)areconnected–theyarenormallyusedforpowerandground.Inthemiddle,thelefthorizontalgroupoffiveholesareconnected,asaretheright.

AnLEDwilllightupwhenthelongerleghaspower(5volts),andtheshorterlegisconnectedtoground(abbreviatedGND).TokeeptheLEDfromusingtoomuchpower,connectthenegativepinoftheLEDtogroundusinga1kohmresistor(stripesarebrown/black/red).

TryconnectingupanLEDtopowerandgroundfromtheArduino–makesureitturnson.Then,connectittopin13ontheboard–itshouldblinkinthesamewayastheLEDembeddedontheArduino.Andnow…Moveittoconnecttopin12,andhavethemalternateonandoff….

AddsomemoreLEDs,usingotherpinsfromtheArduino.Canyoubouncethelightsbackandforth?Getthemtocount?

Onceyou’vegotthatgoing….Therearesomespeakers.CheckouttheToneMelodysketch.