Monday, March 22, 2010
Task 43 - Project Websites
http://hacknmod.com/hack/top-40-arduino-projects-of-the-web
This website has some great projects such as the gameboy.
http://www.coolcircuit.com/gadgets/category/arduino/
This website also has some amazing products such as the wireless harp, I think it would be wicked to make something like that.
http://missionduke.com/arduino-projects/
This website has a great project with Itunes and the Arduino, however I don't like apple therefore I don't use Itunes, however something could made similar with Windows Media Player.
http://www.instructables.com/
This website has step by step guides into making some of the projects, however you have to register to access some things.
Task 42 - Rules on YABB
- No False Material
- No abusive , harassing behaviour
- No inaccurate material
- No hateful / threatening language towards other
- Treat everyone with respect
- Be polite
- No abusive , harassing behaviour
- No inaccurate material
- No hateful / threatening language towards other
- Treat everyone with respect
- Be polite
Thursday, March 18, 2010
Task 40 - Article from YABB
Task 39 - Same As Task 38 With Different Output
//Program to output the value of your LDR whenever you press the button.
int buttonPin = 2; // the number of the pushbutton pin
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
int buttonState = 0; // variable for reading the pushbutton status
int count = 1;
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
photocellReading = analogRead(photocellPin);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.print("Reading number ");
Serial.print(count);
Serial.print(": ");
Serial.println(photocellReading);
delay(500);
count++;
}
else {
buttonState == LOW;
}
}
int buttonPin = 2; // the number of the pushbutton pin
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
int buttonState = 0; // variable for reading the pushbutton status
int count = 1;
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
photocellReading = analogRead(photocellPin);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.print("Reading number ");
Serial.print(count);
Serial.print(": ");
Serial.println(photocellReading);
delay(500);
count++;
}
else {
buttonState == LOW;
}
}
Task 38 - Program to output the value of your LDR whenever you press the button.
//Program to output the value of your LDR whenever you press the button.
int buttonPin = 2; // the number of the pushbutton pin
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
photocellReading = analogRead(photocellPin);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.print("Analog reading = ");
Serial.println(photocellReading);
delay(500);
}
else {
buttonState == LOW;
}
}
int buttonPin = 2; // the number of the pushbutton pin
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
photocellReading = analogRead(photocellPin);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.print("Analog reading = ");
Serial.println(photocellReading);
delay(500);
}
else {
buttonState == LOW;
}
}
Sunday, March 14, 2010
Task 37 - Baud Rate
I have found with using the code from task 36, I could increase the baud rate upto 28800 before it started to become scrambled on the screen. The least amount of baud rate I could use was 9600, if I used anything less, the words became scrambled or wouldn't show anything on the screen.
Friday, March 12, 2010
Task 36 - Random Numbers with Mean
// Adam Randall - Random Numbers Program, generates 100 random numbers between 1 and 10 and display mean.
long randNumber;
int total;
int mean;
void setup(){
total =0;
mean =0;
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.print(i);
Serial.print(": ");
Serial.println(randNumber);
total = total + randNumber;
delay(500);
}
mean = (total/100);
Serial.println ("The Mean is: ");
Serial.print(mean);
}
void loop() {
}
long randNumber;
int total;
int mean;
void setup(){
total =0;
mean =0;
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.print(i);
Serial.print(": ");
Serial.println(randNumber);
total = total + randNumber;
delay(500);
}
mean = (total/100);
Serial.println ("The Mean is: ");
Serial.print(mean);
}
void loop() {
}
Task 35 - Random Numbers with numbers in front
// Adam Randall - Random Numbers Program, generates 100 random numbers between 1 and 10
long randNumber;
void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.print(i);
Serial.print(": ");
Serial.println(randNumber);
delay(500);
}
}
void loop() {
}
long randNumber;
void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.print(i);
Serial.print(": ");
Serial.println(randNumber);
delay(500);
}
}
void loop() {
}
Thursday, March 11, 2010
Task 34 - Random Numbers
// Adam Randall - Random Numbers Program, generates 100 random numbers between 1 and 10
long randNumber;
void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.println(randNumber);
delay(500);
}
}
void loop() {
}
long randNumber;
void setup(){
Serial.begin(9600);
randomSeed(analogRead(0));
for (int i=0; i<100; i++){
randNumber = random(0, 10);
Serial.println(randNumber);
delay(500);
}
}
void loop() {
}
Sunday, March 7, 2010
Task 29 - Resources
http://http//webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/index.html
This website has some great arduino projects and has pictures of the arduino setup and the circuit board, so the user can create it.
http://http//www.practicalarduino.com/news/id/461
The above link is to website about an Arduino book called: Pratical Arduino. Looks like it would be a good book to own to make some interesting projects with.
http://http://falconphysics.blogspot.com/2009/01/arduino-in-high-school-electronics.html
This website is a techers blog about teaching and using the arduinos. It seems like a very cool idea and I wish this happened in my highschool. Even the video of the robot is cool.
This website has some great arduino projects and has pictures of the arduino setup and the circuit board, so the user can create it.
http://http//www.practicalarduino.com/news/id/461
The above link is to website about an Arduino book called: Pratical Arduino. Looks like it would be a good book to own to make some interesting projects with.
http://http://falconphysics.blogspot.com/2009/01/arduino-in-high-school-electronics.html
This website is a techers blog about teaching and using the arduinos. It seems like a very cool idea and I wish this happened in my highschool. Even the video of the robot is cool.
Friday, March 5, 2010
LED Project - Assignment 1
// Melody by Adam Randall
// This is a program designed to output LED's when notes are played
// through a speaker. Below is the code used.
int speakerPin = 12; // output Speaker
int led1 = 9; // output LED1
int led2 = 8; // output LED2
int led3 = 7; // output LED3
int led4 = 6; // output LED4
int led5 = 5; // output LED5
int led6 = 4; // output LED6
int length = 24; // the number of notes
char notes[] = "ggcGfcg ggcGfcg bcAcAbA "; // a space represents a rest
int beats[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int tempo = 300;
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH); // speaker on
delayMicroseconds(tone); // delay
digitalWrite(speakerPin, LOW); // spaker off
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = {'d', 'e', 'f', 'g', 'a', 'b', 'c', 'G', 'A'}; // notes
int tones[] = {587, 659, 698, 784, 880, 988, 1047, 831, 932 }; // frequency
if (note == 'c') {
digitalWrite (led1, HIGH); // LED1 on
delay (50); //delay
digitalWrite (led1, LOW); // LED1 off
}
else if (note == 'g') {
digitalWrite (led2, HIGH); // LED2 on
delay (50); //delay
digitalWrite (led2, LOW); // LED2 off
}
else if (note == 'G') {
digitalWrite (led3, HIGH); // LED3 on
delay (50); //delay
digitalWrite (led3, LOW); // LED3 off
}
else if (note == 'b') {
digitalWrite (led4, HIGH); // LED4 on
delay (50); //delay
digitalWrite (led4, LOW); // LED4 off
}
else if (note == 'A') {
digitalWrite (led5, HIGH); // LED5 on
delay (50); //delay
digitalWrite (led5, LOW); // LED5 off
}
else if (note == 'f') {
digitalWrite (led6, HIGH); // LED6 on
delay (50); //delay
digitalWrite (led6, LOW); // LED6 off
}
// play the tone corresponding to the note name
for (int i = 0; i < 20; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}
void setup() {
pinMode(speakerPin, OUTPUT);
}
void loop() {
for (int i = 0; i < length; i++) {
if (notes[i] == ' ') {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
// pause between notes
delay(tempo / 2);
}
}
Below is a video of th assignment at work:
Task 32 - Push Button Project + Serial output stating the condition of LED and Button.
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.println("Button Pressed, LED on");//
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
Serial.println("Button Pressed, LED off");
}
}
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.println("Button Pressed, LED on");//
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
Serial.println("Button Pressed, LED off");
}
}
Task 31 - Reversed Push Button Project
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED off:
digitalWrite(ledPin, LOW);
}
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED off:
digitalWrite(ledPin, LOW);
}
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
Thursday, March 4, 2010
Task 30 - Push Button Project
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Key Words Glossary
setup() - Used to initialised varibles as the start of a program eg pinMode(buttonPin, INPUT);
loop() - Loops anything you state on the board eg void loop()
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialWrite('L');
delay(1000);
}
digitalWrite - DigitalWrite is used to output something such as an LED as HIGH (on) or LOW (off) eg digitalWrite(ledPin, HIGH);
analogRead()- Reads the value from the specified analog pin eg int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Serial.print()- Prints data to the serial port as human-readable ASCII text. eg •Serial.print("Hello world.") gives "Hello world."
Serial.println()- Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). eg Serial.println("Hello world.") followed by a new line
pinMode()- Configures the specified pin to behave either as an input or an output. eg pinMode(ledPin, OUTPUT); // sets the digital pin as output
digitalRead() - Reads the value from a specified digital pin, either HIGH or LOW. eg
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
loop() - Loops anything you state on the board eg void loop()
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialWrite('L');
delay(1000);
}
digitalWrite - DigitalWrite is used to output something such as an LED as HIGH (on) or LOW (off) eg digitalWrite(ledPin, HIGH);
analogRead()- Reads the value from the specified analog pin eg int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Serial.print()- Prints data to the serial port as human-readable ASCII text. eg •Serial.print("Hello world.") gives "Hello world."
Serial.println()- Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). eg Serial.println("Hello world.") followed by a new line
pinMode()- Configures the specified pin to behave either as an input or an output. eg pinMode(ledPin, OUTPUT); // sets the digital pin as output
digitalRead() - Reads the value from a specified digital pin, either HIGH or LOW. eg
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}
Subscribe to:
Posts (Atom)