+ All Categories
Home > Documents > Week 10 Today 1.Homework presentations and critique. 2.Review digital and analog inputs. 3.DIY -...

Week 10 Today 1.Homework presentations and critique. 2.Review digital and analog inputs. 3.DIY -...

Date post: 25-Dec-2015
Category:
Upload: timothy-gilbert
View: 214 times
Download: 1 times
Share this document with a friend
23
Week 10 Today 1. Homework presentations and critique. 2. Review digital and analog inputs. 3. DIY - jumpers, soldering etc.
Transcript

Week 10Today

1. Homework presentations and critique.

2. Review digital and analog inputs.

3. DIY - jumpers, soldering etc.

HomeworkThose who did not show last week show:1. Either Knight Rider or Shooting Star2. Potentiometer3. New version of above with a control structure

This week’s assignments:1. Multiple switch assignment - make a project that uses at least 2 for

interesting outputs.2. Create project with two HOMEMADE switches.3. Create a cool creative piece using at least one photocell and one other

sensor and two LEDs or other outputs. This should be more than just some lights on your board, it should feel more finished - like the eyes project. As a class we’ll crit and vote on the best ones - they’ll get an extra credit mark.Criteria: creativity, function, ability to explain code, clarity of codeTHIS ONE MUST BE LIVE AND WORKING IN CLASS.

Review

Arduino Sketch Structure• Top of sketch

– Declare variables at top

• Initialize– setup() – run once at beginning, set pins

• Running– loop() – run repeatedly, after setup()

Pins can be changed in loop() too, but conceptually easier in setup()

Arduino Programming

Arduino Programming

Known Good Configuration

Rule #1 of experimenting:Before trying anything new,

Get back to a known working state

Get your entire edit->compile->upload->run workingEven if it becomes so second nature to you that you feel you shouldn’t need to, do it anyway.Especially when mysterious problems arise, revert to a known state

Digital Input

Switches make or break a connectionMost inputs you’ll use are variations on switchesFundamentally, they’re all like the simple knife switch

Knife Switch Toggle Switch

Digital InputSwitches make or break a connection But Arduino wants to see a voltage Specifically, a “HIGH” (5 volts) or a “LOW” (0 volts)

Analog InputsMany states, not just two (HIGH/LOW)

Arduino has six ADC inputs (ADC = Analog to Digital Converter) Reads voltage between 0 to 5 volts Resolution is 10-bit (1024 states)

You used this for the Potentiometer Homework exercise

An Analog Sensor

Photocell, photoresistor, light-dependent resistor A variable resistor ANALOG Brighter light == lower resistance Photocells have range approx. 0-10k

schematic symbol

Reading DiagramsAnalog Sensor w/o Arduino shown

PowerPhotocellCommon JoinArduino pin(Analog pin 0)ResistorGround

Reading DiagramsSwitch w/Arduino

PowerLEDArduino pin(Digital pins)GroundResistorSwitch

Break, 10 minutes.

Do It Yourself!The exciting part of all this is that you can make almost anything…. If you are careful, thoughtful, and test, retest, and document your work.

Doing It Yourself

Making Jumper Wires• strip off about 1/2” of insulation• Can use wire strippers, cutters, or fingers• Can be a pain.. so often use pre-cut wires to

save time but they do cost more.

Doing It Yourself

The End Result ready to go in the Breadboard

Doing It Yourself

Soldering•Permanent connections•When inputs and outputs need to be further

away from the breadboard

•Demonstration (if we go to DT lab)

•Be careful not to overheat•Watch for good connections•Protect solder joints with hot glue when they

are likely to be delicate or subject to stress•Ventilation is good if you are doing a lot of it

Talking to the computer

Communicating with Others•Arduino can use same USB cable for

programming and to talk with computers

•Talking to other devices uses the “Serial” commands

• Serial.begin() – prepare to use serial• Serial.print() – send data to computer• Serial.read() – read data from computer

Can talk to not just computers. Most things more complex than simple sensors/actuators speak serial.

Talking to the computer

Watch the TX/RX LEDS

• TX – sending to PC• RX – receiving from

PC

Used when programming or communicating

Talking to the computer

“serial_hello_world”

• Send “Hello world!” to your computer (and blink LED)

• Click on “Serial Monitor” to see output

• Watch TX LED compared to pin13 LED

Assgn 1Do this. Get it

working and save it.

Telling Arduino what to do…“serial_read_basic”(get from ‘examples’)

• In “Serial Monitor”type “H”, press Send

• Watch pin 13 LED blink onceNotice how you might not

always read something, thus the “-1” check.

Assign 2:Modify to print “hello world”

after it receives something, but before it checks for ‘H’.

This way you can verify it’s actually receiving something.

Cool! Now what?Now it’s your turn!

Assignment 3:Add other outputs onto your board. Use different key commands to

trigger them.

Assignment 4:Get data in from an analog sensor and print it out in at least 3 formats.

(hint: http://www.arduino.cc/en/Serial/Println)

Assignment 5:Add other responses on the screen and have different sensors trigger

them.

HomeworkComplete and post your work (description of project, photo of it, plus code)Assignment 1: Get basic serial communication working.

Assignment 2: Modify to print “hello world” after it receives something, but before it checks for ‘H’. This way you can verify it’s actually receiving something.

Assignment 3: Add other outputs onto your board. Use different key commands to trigger them.

Assignment 4: Get data in from an analog sensor and print it out in at least 3 formats. (hint: http://www.arduino.cc/en/Serial/Println)

Assignment 5: Add other responses on the screen and have different sensors trigger them.

Extra Credit: Refine your best piece from last homework further and show in class at next class.


Recommended