Electronics/Programming
Intro
We had to make a project using Arduinos. I made one that plays part of Beethoven's Moonlight Sonata Movement III.
ELECTRICITY
Concepts
Concept |
Description |
Unit |
Equation |
Voltage
|
Electrical potential
|
Volts = (kg*m^2)/(Coulomb*s^2)
|
V=IR,
|
Current
|
Flow of electricity
|
Amperes (Amps) = Coulomb/s
|
Current into a node = current out of it
|
Resistance
|
How hard it is for electricity to flow
|
Ohms = (kg*m^2)/(Coulomb^2*s)
|
Series: R = R1 + R2 + R3 + ...
Parallel: R = 1/((1/R1)+(1/R2)+(1/R3)+...) |
Power
|
energy use per second
|
Watts = (kg*m^2)/(s^3)
|
P=VI
|
Breadboard
All the "minus" pins on the left are connected to each other.
All the "minus" pins on the right are connected to each other.
All the "plus" pins on the left are connected to each other.
All the "plus" pins on the right are connected to each other.
A-n, B-n, C-n, D-n, E-n are connected for any 0<n<=30.
F-n, G-n, H-n, I-n, J-n are connected for any 0<n<=30.
All the "minus" pins on the right are connected to each other.
All the "plus" pins on the left are connected to each other.
All the "plus" pins on the right are connected to each other.
A-n, B-n, C-n, D-n, E-n are connected for any 0<n<=30.
F-n, G-n, H-n, I-n, J-n are connected for any 0<n<=30.
PROGRAMMING
Concepts
Comment
|
//This next function does this...
|
//:Signals that the rest of the line is a comment, and will not be read as code.
A multi-line comment can be done like this: /* commenting commenting commenting commenting */ |
Function Definition
|
void loop(){
//code goes here } |
void: function does not output anything
loop: the name of the function (): Inputs would be listed between the parentheses. There are none here. {}: The code that the function runs goes here. |
if(condition){
//code1 here } else{ //code2 here } |
if(n%2==0){
n/=2; } else{ n*=3; n+=1; } |
If condition is true, run code1. Otherwise, run code2.
|
Arduino-Specific
delay(ms)
|
delay(250)
|
waits ms milliseconds, then continues
|
pinMode(pin, INPUT/OUTPUT)
|
pinMode(13,OUTPUT)
|
Makes a pin an input or output pin.
|
tone(pin, frequency)
tone(pin, frequency, duration) |
tone(13, 440)
tone(13, 440, 1000) |
Creates a square wave on pin pin at frequency frequency for duration milliseconds.
This can be connected to a buzzer to play a tone. |
For more arduino-specific functions, see http://www.arduino.cc/
Reflection
This project just felt like an exercise from the computer class I took recently, plus connecting a few wires into a breadboard.