WEEK OF SEPT 13
This lab will introduce you to the basics of robot sensation. As a result, you’ll become familiar with general safety guidelines for the COGS lab and basic circuitry. Start by programming and completing the circuit the LED blink activity, the “Hello World!” equivalent for Arduino, then move on to sensing.
This is also the first time you will be working with your team. You may find that you have to divide the work up to be able to complete the whole lab in time. Before starting, have a brief discussion about what everyone feels comfortable doing and what everyone would like to have practice with. Delegate tasks by balancing each person’s strengths with each person’s weaknesses. You may want to delegate roles such as note-taker, coder, circuit-builder, coordinator, and/or explainer.
Challenges are offered to guide your creative expression and are not necessary to complete. We’re happy with you coming up with your own challenges!
- Review the Arduino Uno schematic in the appendix and circuitry basics,
- Run through this Arduino Set Up Tutorial
- Skim over the COGS 300 Lab Manual
- Draft a circuit that connects Arduino Pin 13 to a resistor then to an LED then to ground.
- Download the Arduino IDE
Part 1: Safety Overview
In the COGS 300 Lab, you will be handling live current. You can cause damage to yourself, others and your equipment unless you are being careful.
With that in mind, please adhere to the following guidelines:
- Don’t touch leads together (power to ground with no resistance)
- Always set up your circuit “from the ground up” – set up your ground first, and plug in your power source last.
- If you break a component or need something extra, talk to your TA.
- Always charge your batteries when you are finished.
- Refrain from using batteries before a lab you are not in – this will make it more difficult for other groups to perform their lab tasks as they will be working with drained batteries. Instead, recharge them.
- Clean up your workstation completely after you are done. This means putting away Lego into the right bins, putting all your components back into your bin, and throwing away any garbage.
- Always use electrical tape to cover bare wire.
Part 2: Blink Program
Materials: 1x Arduino, 1x Resistor (resistance between 230 ~ 5k Omhs is okay), 1x LED
- Follow the Arduino Blink tutorial to build your circuit. Remember, you can damage your board if things are not plugged in correctly, so show your TA if you are unsure.
The code is pretty self explanatory, but notice the general structure of the code. It starts with a setup function, where relevant variables are declared, while the actual functionality of your Arduino is dictated by the contents of the loop function.
Part 3: Potentiometers
Everyone should complete this portion on their own board.
- Build a circuit the circuit shown in this instructable.
- Make sure you read the output in the Serial Monitor. You can find the Serial Monitor under “Tools” for Windows. Does it make sense?
- Make two circuits!
- Take the unused analog output and attach an LED. Use the Blink circuit as a guide, but attach the LED to pin 09. Remember that the LONG end of the LED is for the “power” and the SHORT end is for the “ground.”
- Make the LED change brightness depending on the potentiometer output.
- If you’d like, show your TA that it works.
Part 4: Photoresistors
Depending on the size of your group, you may find it useful to use some people’s breadboards to work ahead or test other circuit configurations. Keep this portion on at least one person’s breadboard to show the TA at the end.
- Build a circuit the circuit shown in this instructable
- You can run the program from the instructable as is, but it might be helpful to add Serial.begin(9600); to the setup function of the program. Then add Serial.println(value); to the loop function of the program. Then go to the Serial Monitor to see the output values.
- If you’re not getting good responsiveness, try varying the brightness threshold (at 25 in the above instructable).
- Modify the program and circuit to vary LED brightness with photoresistor readings.
- Show your TA before moving onto the challenge component.
Optional Challenge: Ultrasonic sensor
Challenge components are offered to help deepen your understanding of the material and provide insight into future labs. Labs are designed so that you should be able to get to the challenge component with enough time, especially if you are dividing the work. However, it is important information for us if you cannot complete the lab in time, so tell your TA if you’re stuck!
- Build a circuit for the Ultrasonic sensor show in this resource.
- Scroll down and use the Source code with New Ping.
- Download and use the New Ping Library by going to Tools > Manage Libraries… and then searching for “New Ping” in the top search bar.
- Program the Arduino to output distance in inches and centimetres.
- Play with all of the components you learned about today. What can you make them to together?
- Show the TA and post to Discord.
Go to the Discord server and post a hello message. Include a picture of any of your circuits!
Feel free to review other Arduino resources for sensors/other attachments relevant for the COGS Lab this term:
- Make sure you’ve chosen the correct port and console
- longer stick on the LED is the positive side
- always use a resistor!
- Copying and pasting code doesn’t always work, you may need to type it out!
- When printing out things in the console, make sure you have Serial.beging(9600); in your setup
- If blink doesn’t work, change your arduino
(Click the photo below for larger image!)