Castle Blue Don't Come Through!
by ramerame13 in Circuits > Arduino
166 Views, 0 Favorites, 0 Comments
Castle Blue Don't Come Through!
Here I will show you how to make a castle that has lights that turn on and dim with a push of a button and and a twist of a potentiometer and a flag that waves when an object is sensed in front of an ultrasonic sensor. This was my first real project in circuitry. I made a lot of mistakes that I learned quite a bit from! Here I will share that information and my process with you!
Supplies
Arduino Uno
Potentiometer
Button
Ultra sonic sensor
Servo motor
Breadboard
3 LED's
Jumper wires
Resistors
Hot Glue
Solder
Sticky tack
Velcro
Wooden castle
Straw
Colored paper
Cardboard
LED's
First, I cut three long pieces of white and three long pieces of black wire to serve as my ground and power cables for three LED's. These have to be long to go from the front of the castle to the breadboard in the back. Next, I soldered one black wire to the short end of one LED and one white wire to the long end of the LED and repeated this process for the other two LED's. I hot glued the LED's to the front of the castle and plugged the other end of the wire into row 10 on the breadboard, three white on one side of the board and three on the other. I also plugged a resistor in row 10 connecting to ground and a jumper wire from 10 to 5 on the Arduino Uno.
Ultrasonic Sensor
Next, I drilled a hole in the back of the castle. I also cut one long red, one long black, and two long white cables to connect to the ultrasonic sensor. I soldered the black wire to the ground pin, the red to VCC, one white to Trig, and one white to Echo. I made a cardboard door with holes for the sensor. I pulled the cables through the back hole and connected the white wires to 6 and 7 on the digital side of the microcontroller, the black to ground on the board, and the red to power on the board. Then I adhered the door. I used tape initially to be able to easily troubleshoot the ultrasonic sensor but plan on adhering it with hot glue once everything is perfect.
Servo Motor
I put a bit of velcro on the back of the castle and bottom of the servo motor and adhered the motor to the castle. I used sticky tack to adhere a flag made from a straw and colored paper to the top of the motor. I plugged the orange cable into 9 on the digital side of the Arduino, red to power on the board, and black to ground.
Potentiometer and Button
I plugged the potentiometer into the breadboard. The two outer pins of the potentiometer need to be connected to power and ground and the center pin is your signal pin that I connected to A5 on the microcontroller. Next, I plugged in a button that straddles the center of the board. One side is connected to power and the other is connected to 13 on the microcontroller. I also plugged a resistor to ground from the signal side of the button. Lastly, I plugged the board into power and ground on the microcontroller.
Code
https://gist.github.com/ramerame13/eead7c1b96964bbaf175760c4da7132e