It's time to put what we've learned together into a (basic) project. Here's what we've worked on so far:
- Connecting the Arduino to a computer
- The Arduino IDE and uploading sketches
- Using jumper wires with a solderless breadboard
- Safely powering LEDs with Arduino
- Using pins on Arduino as digital outputs and digital inputs
- Using a momentary push button switch to indicate a logic state
- Various Arduino commands and syntax, including
At this point, you don't need to be an expert on all of the above-mentioned topics, but you should at least have a basic recollection of what we did and how they work. Go back and revisit our previous activities if necessary before continuing with this project.
- defining and assigning variables
- pinMode()
- digitalWrite()
- digitalRead()
- if()
- else()
- delay()
Click through the break to begin this project:
First, the Rules... ...
In this project, you may:
- Talk with other groups about what they are doing
- Look at other groups' circuits
- Research online to see example code
- Copy and paste parts of code from outside sources.
- Use / repurpose code we've previously used in this class for our activities
- Ask for help from outside sources
You may not:
- Touch another group's circuits (or ask another group to touch your circuits)
- Physically type code into another group's computer (or ask another group to type code into your computer)
- Copy and past code directly from a classmate
Eventually, we will all be working on different projects, so we can ease up a bit on the rules about not touching others' stuff, but for now, we need to make sure everyone is help accountable for their own learning.
The Project:
Your goal is to design a specialized "flashlight" that has the following properties:
- Arduino-controlled
- Features 2 LEDs (that are each protected with an appropriate resistor)
- A single push-button switch that controls the light as follows:
- Initially, the flashlight is off (both LEDs are off)
- On the first press of the button, one LED lights
- On the second press of the button, the first LED turns off and the second LED lights
- On the third press of the button, both LEDs turn on
- On the fourth press of the button, the flashlight turns off again
- The switch should not need to be continuously pressed--the presses simply toggle the flashlight through its four modes: off, LED 1, LED 2, both LEDs, off, etc.
Hints to Get Started:
- Start by connecting the +5 V pin to a "power" (red) rail on your breadboard and the GND pin to a "ground" (blue or black) rail.
- In addition to +5 V and GND, you will need to use three additional pins: two as outputs to turn the LEDs on or off, and one for an input to monitor the state of your button.
- You might want to use the last sketch we worked on (the one with the two serial output states) to get started.
When you're finished:
https://learn.adafruit.com/adafruit-arduino-lesson-10-making-sounds
No comments:
Post a Comment