Arduino is an open-source physical computing platform designed to make experimenting with electronics more fun and intuitive. Arduino has its own unique, simplified programming language, a vast support network, and thousands of potential uses, making it the perfect platform for both beginner and advanced DIY enthusiasts.
The Code
digitialWrite and delay are what makes this circuit work. digitialWrite allows you to set the code to low or high. Low is 0v and high is 5v. When digitialWrite is set to high the LED turnd on and vise versa. Delay is what allows the LED to blink. Delay can be set to any specific amount of time but is in milliseconds. As you can see in this code delay is set to 1000 making the LED turn off for a second and then back on for a second.
Process:
How does the potentiometer work?
The potentiometer is a voltage divider. As you turn the potentiometer the voltage to the LED increases or decreases from 0v to 5v; increasing or decreasing the speed of the blink.
The process
The code
digitalWrite and delay are 2 of the few very important code to this specific circuit. In this circuit the digitalWrite allows for the colors to switch by setting them to LOW or HIGH in specific situations, as well as delay which allows colors to come on at certain times for certain durations. Another important piece of code is the const int, this peice of code controls how fast the shift through each other.
The process
The code
DigitalWrite and delay are the main codes that make this circuit run. digitalWrite allows for the LEDs to turn on in the specific order. Delay allows the LEDs to turn on for the correct amount of time to make the LEDS switch between each other in the correct order.
The code
pinMode is a very important part of this code. pinMode allows the buttons to be declared a variable/ an input which is key in making them turn on and off the LED. pinMode also allows the LED to be declared an output which also contributes to the on and off function the push button provides. button1state and button2state are also very important when paired with digitalRead. This line of code allows for when button is pressed to connect to the GND and when not pressed connect to the 5v.
The code
if than statement is the only reason this circuit functions the way it does. In this particular code the if statement is set to if (lightlevel< low) than low equals lightlevel low and vise versa as if the if statement is set to (lightLevel> high) than high equals lightLevel. This allows the photo sensor to react correctly to the amount of light, dimming or brightening the LED.
The process
manualTune allows the user to manually change the range from light to dark. There is howerever pros and cons to this use of this line of code. Some of the pros are manually being able to change the range of full on to full off, which can possibly allow you to see better results. A con is possible user error which can cause the circuit not work properly.
autoTune allows the user to rely on the arduino to do all the work when changing the range from full on to full off. There are also pros and cons to this function. A pro is the ability to not encounter user error and see correct results from the circuit without much of a problem. A con is possibly lacking understanding of how the code works from not being able to play with it manually. Another con may be the way the light is in the room, when using autoTune it may not correctly show the LED dimming or brightning due to the way the light is taken in by the photo sensor. With manualTune this really shouldnt be as much as a problem because you can change the range.
The code
The code for circuit seven is a little different from the rest. The code for circuit seven allows you to open up a serial port to see what temperatures the temperature sensor is recording.
Process
If you look closely you can see the LED brightening just a little when the temperature reaches above 70.2 degrees F. My partner and I changed the code to include an if then statement that allowed the LED to brighten when temp> 70.2 F
The Code
This code is unique to all other code. This code includes a servo.write and delay. These 2 fuctions together allow for the servo to stop for a certain amount of time and then change position and start again. Another really important part of the code is the position=0 and position< 100 ect. These lines of code allow the servo to change direction and spin in other ways.
The process
Me and my teammate manipulated the code so that the servo could stop, change positions, and start again.
If you closely into the blue plastic you can see the bottom of the white part spinning, stopping, and then changing direction
The code
The code in this circuit includes char notes and int beats. These 2 codes allow the buzzer to play songs. The char notes are what allows the voltage to sound a specific way. Int beats is a collection of values for each note as well as rest which is what creates the structure of the song. int tempo is also included to speed up or slow down a song.
The code
digitalWrite, int Speed, and delay are the lines of code that allows the motor to spin. DigitalWrite allows the motor to turn on, while int Speed allows the motor to change speeds. delay allows the motor to turn off delay off time for a certain amount of time
The process
Me and my partner manipulated specifically the int speed function greatly increases the speed of our motor.
The code
Code like const timeDelay, delay, and digitalWrite are what allow this circuit to function properly. The const timeDelay allows delay for the on and off phases of the LEDS, which allows you to accurately see the switch between the LEDS. Delay allows for the switch to happen; turning one LED off for a certain amount of time while the other stays on. digitalWrite allows for the LED to actually turn on and off. The digitalWrite changes the amount of volts going into the LED when labled HIGH or LOW, HIGH being on 5 volts and LOW being off 0v.
The code
There is lots of important code for circuit 12, even though it is just like circuit 4 it uses a shift register instead. 1 important line of code is the shiftWrite which works exactly like digitalWrite but just applies to a shifter. shiftWrite allows an LED to turn on using the variable HIGH (5v/on) or LOW(0v/off). Another really important line(s) of code is the int datapin, int clockpin, and int latchpin. This line of code allows the serial connection SPI (serial peripheral interface) which requires those 3 pins to be declared a varible.