Wednesday, July 21, 2010
Robotics Tasks
1.) What is a robot?
2.) What are some early robots?
- A robot is an automatically guided machine which is able to do tasks on its own, almost always due to electronically-programmed instructions.
2.) What are some early robots?
Atomic Robot Man
Was one of the earliest known Robot toys from Japan. It is from the same time period (probably the 1940's) as the Tin Lilliput Robot. These early Robots are very primitive and very, very rare. Their makers are unknown.
=============================================Thursday, June 17, 2010
Major Project - Ultrasonic sensor
Transmitter circuit
Receiver circuit
Programe:
int ledPin = 13;
int numChanges = 0;
int MAX_TIME = 1000;
boolean changed = false;
boolean prevReadHigh = false;
int startTime;
int finishTime;
void setup() {
pinMode(ledPin, INPUT);
Serial.begin(9600);
}
void loop()
{
finishTime = (millis() + MAX_TIME);
numChanges = 0;
changed = false;
prevReadHigh = false;
while(millis() <= finishTime)
{
if (digitalRead(ledPin) == HIGH)
{
Serial.println("high");
if (prevReadHigh != true)
{
prevReadHigh = true;
numChanges++;
}
}
else
{
Serial.println("low");
if (prevReadHigh != false)
{
prevReadHigh = false;
numChanges++;
}
}
}
Serial.println(numChanges);
delay(100);
}
Process:
1: Set up both circuits on a single bread board
2: changed the voltage to the receiver from 9 volts to 5 volts so that the arduino could handle it. (still not sure what effect this had on the project)
3: wrote programe
4: realized that the receiver receives pulses (not just one consistent voltage) and therefor had to rewrite my programe to count the pulses.
5: tried using buzzers and LED's to get a signal from the transmitter but soon after realized that the pulses are to fast for ether of them to pick it up.
6: applied a "ground" to several IC pins after realizing they were not connected.
7: ended up getting what looked like a pulse on the LED and had some variance when I moved the transmitter closer to the receiver which lead me to believe that the transmitter was actually transmitting.
8: couldn't manage to read the pulses in the arduino due to a lack of voltage which I am still unsure of.
Receiver circuit
Programe:
int ledPin = 13;
int numChanges = 0;
int MAX_TIME = 1000;
boolean changed = false;
boolean prevReadHigh = false;
int startTime;
int finishTime;
void setup() {
pinMode(ledPin, INPUT);
Serial.begin(9600);
}
void loop()
{
finishTime = (millis() + MAX_TIME);
numChanges = 0;
changed = false;
prevReadHigh = false;
while(millis() <= finishTime)
{
if (digitalRead(ledPin) == HIGH)
{
Serial.println("high");
if (prevReadHigh != true)
{
prevReadHigh = true;
numChanges++;
}
}
else
{
Serial.println("low");
if (prevReadHigh != false)
{
prevReadHigh = false;
numChanges++;
}
}
}
Serial.println(numChanges);
delay(100);
}
Process:
1: Set up both circuits on a single bread board
2: changed the voltage to the receiver from 9 volts to 5 volts so that the arduino could handle it. (still not sure what effect this had on the project)
3: wrote programe
4: realized that the receiver receives pulses (not just one consistent voltage) and therefor had to rewrite my programe to count the pulses.
5: tried using buzzers and LED's to get a signal from the transmitter but soon after realized that the pulses are to fast for ether of them to pick it up.
6: applied a "ground" to several IC pins after realizing they were not connected.
7: ended up getting what looked like a pulse on the LED and had some variance when I moved the transmitter closer to the receiver which lead me to believe that the transmitter was actually transmitting.
8: couldn't manage to read the pulses in the arduino due to a lack of voltage which I am still unsure of.
Sunday, May 2, 2010
Task check list
1) Create a blog.
- www.vinniees.blogspot.com
- www.vinniees.blogspot.com
2) Put link into Moodle wiki. (Moodle not ready yet.)
- done
- done
3)Fill in rest of your details on Moodle wiki
- done
- done
4)Check out all the sites related to the list in the embedded notices blog.
Write a sentence about what each one does. You don't have to be very familiar with each one.
- Within the navigation
- Within the navigation
5) Find 4 more Arduino LED related videos in Youtube, BlipTV etc. Put a link and a two-sentence review about each one in your blog. Be prepared to talk about one or more of them.
- http://vinniees.blogspot.com/2010/03/youtube-arduino-leds.html
- http://vinniees.blogspot.com/2010/03/youtube-arduino-leds.html
6) Establish a sketchpad folder in the D Drive or in a USB pen.
- done
7 - 22) programes
- http://vinniees.blogspot.com/2010/03/programmes.html
23) put at least one Arduino variety, like Freeduino, into this wiki with a screen shot and put a link and a comment back into your blog so that it can be verified.
- done
24) Put a link and comment about this page in your blog. Identify your LDR from your pack.
- http://vinniees.blogspot.com/2010/02/links.html
25) Start a Arduino key words page in your blog. Put every new key word with an explanation and example when you come across it.
- http://vinniees.blogspot.com/2010/02/arduino-keywords.html
26) Run the ladayada photocell program that was handed out in class. Write it up in your blog about what you did and the program.
- Missed that class and didn't get hand out.
27) Same as 26 above but make some changes to improve it. Put your changes into a comment so that it's obvious what the differences are.
- - Missed that class and didn't get hand out.
28) Write a program to turn a LED on whenever the light is blocked to your LED. You will have to play around with several values.
- http://vinniees.blogspot.com/2010/03/programmes.html
29) Check out the wikiEducator site that has some example Arduino resources. Read the directions there about doing another one. Create one like it in your blog or create it in wikiEducator by registering and starting your own pages. If your resources page is not in your blog, create a heading and a link to it so that it can be marked.
- http://vinniees.blogspot.com/2010/03/arduino-resources.html
30 - 39) programes
- http://vinniees.blogspot.com/2010/03/programmes.html
40)Find an interesting article on the YABB news section and provide a screen shot and a short report on why you found it interesting.
- http://vinniees.blogspot.com/2010/03/yabb-registration.html
41) Register for YABB but don't contribute yet. Take a screen shot of part of your registration process to confirm you've done it.
- http://vinniees.blogspot.com/2010/03/yabb-registration.html
42) Write a short list of rules for a bulletin board like YABB. Watch some thread over two weeks and be ready to make a contribution.
- Not sure want you meant by "rules" here
43) Write a list of four good project sites and include a link and a screen shot for each with a comment in your blog.
- http://vinniees.blogspot.com/2010/03/arduino-resources.html
44) Present to the class a report on one of your assigned devices. You need to tell us what it does and give a little demo of it working on a simple Arduino project. Include in your talk at least three Impress or PowerPoint slides on a USB pen or similar.
- Done with Glenn
45) Explore the way your infrared transmitter sends pulses to the receiver. Set up a little demonstration to be marked in class. You may share this project with another person but both members have to know what's going on. Transmission from one Arduino to another is especially excellent.
- done in class
46 - 50) Using two Arduino's
- done in class
Sender:
int ledPin = 13;
boolean high = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(0, OUTPUT);
}
void loop()
{
if (high)
{
digitalWrite(0, LOW);
digitalWrite(ledPin, LOW);
high = false;
}
else
{
digitalWrite(0, HIGH);
digitalWrite(ledPin, HIGH);
high = true;
}
delay(1000);
}
Receiver
// Communication Pins
const int rxPin = 2;
const int txPin = 13;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
// Initialize the Rx and Tx pins
// Traffic Light LEDs
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
//int i = 1;
pollRxPin();
flipTxPin();
//i++;
delay(1000);
}
void pollRxPin()
{
if( digitalRead(rxPin) == HIGH )
{
//Serial.print(i);
//Serial.print(": ");
Serial.println('H');
digitalWrite( txPin, HIGH );
}
else
{
//Serial.print(i);
//Serial.print(": ");
Serial.println('L');
digitalWrite( txPin, LOW );
}
}
void flipTxPin()
{
}
- done
7 - 22) programes
- http://vinniees.blogspot.com/2010/03/programmes.html
23) put at least one Arduino variety, like Freeduino, into this wiki with a screen shot and put a link and a comment back into your blog so that it can be verified.
- done
24) Put a link and comment about this page in your blog. Identify your LDR from your pack.
- http://vinniees.blogspot.com/2010/02/links.html
25) Start a Arduino key words page in your blog. Put every new key word with an explanation and example when you come across it.
- http://vinniees.blogspot.com/2010/02/arduino-keywords.html
26) Run the ladayada photocell program that was handed out in class. Write it up in your blog about what you did and the program.
- Missed that class and didn't get hand out.
27) Same as 26 above but make some changes to improve it. Put your changes into a comment so that it's obvious what the differences are.
- - Missed that class and didn't get hand out.
28) Write a program to turn a LED on whenever the light is blocked to your LED. You will have to play around with several values.
- http://vinniees.blogspot.com/2010/03/programmes.html
29) Check out the wikiEducator site that has some example Arduino resources. Read the directions there about doing another one. Create one like it in your blog or create it in wikiEducator by registering and starting your own pages. If your resources page is not in your blog, create a heading and a link to it so that it can be marked.
- http://vinniees.blogspot.com/2010/03/arduino-resources.html
30 - 39) programes
- http://vinniees.blogspot.com/2010/03/programmes.html
40)Find an interesting article on the YABB news section and provide a screen shot and a short report on why you found it interesting.
- http://vinniees.blogspot.com/2010/03/yabb-registration.html
41) Register for YABB but don't contribute yet. Take a screen shot of part of your registration process to confirm you've done it.
- http://vinniees.blogspot.com/2010/03/yabb-registration.html
42) Write a short list of rules for a bulletin board like YABB. Watch some thread over two weeks and be ready to make a contribution.
- Not sure want you meant by "rules" here
43) Write a list of four good project sites and include a link and a screen shot for each with a comment in your blog.
- http://vinniees.blogspot.com/2010/03/arduino-resources.html
44) Present to the class a report on one of your assigned devices. You need to tell us what it does and give a little demo of it working on a simple Arduino project. Include in your talk at least three Impress or PowerPoint slides on a USB pen or similar.
- Done with Glenn
45) Explore the way your infrared transmitter sends pulses to the receiver. Set up a little demonstration to be marked in class. You may share this project with another person but both members have to know what's going on. Transmission from one Arduino to another is especially excellent.
- done in class
46 - 50) Using two Arduino's
- done in class
Sender:
int ledPin = 13;
boolean high = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(0, OUTPUT);
}
void loop()
{
if (high)
{
digitalWrite(0, LOW);
digitalWrite(ledPin, LOW);
high = false;
}
else
{
digitalWrite(0, HIGH);
digitalWrite(ledPin, HIGH);
high = true;
}
delay(1000);
}
Receiver
// Communication Pins
const int rxPin = 2;
const int txPin = 13;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
// Initialize the Rx and Tx pins
// Traffic Light LEDs
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
//int i = 1;
pollRxPin();
flipTxPin();
//i++;
delay(1000);
}
void pollRxPin()
{
if( digitalRead(rxPin) == HIGH )
{
//Serial.print(i);
//Serial.print(": ");
Serial.println('H');
digitalWrite( txPin, HIGH );
}
else
{
//Serial.print(i);
//Serial.print(": ");
Serial.println('L');
digitalWrite( txPin, LOW );
}
}
void flipTxPin()
{
}
51. EEPROM read
Friday, March 19, 2010
programmes
7. Blink: Blinks on for one second and off for one second continuously.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
//=================================================================================
8. Quick Blink: Turns on for 10ms and off for one second continuously.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(10); // wait for 10ms
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
//=================================================================================
9. Slow Blink: turns on for one second and off for 10ms continuously.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(10); // wait for 10ms
}
//=================================================================================
10. Rapid Blink: The LED blinks rapidly turning off and on every 10ms.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(10); // wait for 10ms
digitalWrite(ledPin, LOW); // set the LED off
delay(10); // wait for 10ms
}
My cut off point is three. I think it would differ from person to person seen as some people have better eye sight than others.
//=================================================================================
12. alternate blink
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(redLedPin, HIGH); // set the LED off
delay(del); // wait for a second
stop;
}
//=================================================================================
13.mostly on/off
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 250;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH);// set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(subdel); // wait for a second
digitalWrite(ledPin, LOW);// set the LED on
delay(50);
digitalWrite(ledPin, HIGH);// set the LED on
delay(subdel);
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(redLedPin, HIGH); // set the LED off
delay(del); // wait for a second
}
//=================================================================================
16.blink blink, wink
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH);// set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(subdel); // wait for a second
digitalWrite(ledPin, LOW);// set the LED on
delay(50);
digitalWrite(ledPin, HIGH);// set the LED on
delay(subdel);
digitalWrite(ledPin, LOW); // set the LED off
delay(subdel); // wait for a second
digitalWrite(redLedPin, HIGH); // set the LED off
delay(20); // wait for a second
digitalWrite(redLedPin, LOW); // set the LED off
delay(subdel); // wait for a second
}
//=================================================================================
17. blinks 5 times
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
18. blink random amount
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
19. increase rate of blinking
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
20. increase then decrease rate of blinking
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
int i = 0;
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
while (i < i =" 0;">
//=================================================================================
21. output word, "blink"
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
Serial.println("blink");
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200); // wait for a second
}
//=================================================================================
22. output colour of LED that is on
*/
int redLedPin = 13;// LED connected to digital pin 13
int yellowLedPin = 12;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
Serial.begin(9600);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(redLedPin, HIGH); // set the LED on
Serial.println("red");
delay(200); // wait for a second
digitalWrite(redLedPin, LOW); // set the LED off
delay(200); // wait for a second
digitalWrite(yellowLedPin, HIGH); // set the LED on
Serial.println("yellow");
delay(200); // wait for a second
digitalWrite(yellowLedPin, LOW);// set the LED off
delay(200); // wait for a second
}
//=================================================================================
30. Button push
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 7.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave
modified 17 Jun 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
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);
}
}
//=================================================================================
31. reverse button
// constants won't change. They're used here to
// set pin numbers:
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);
}
}
//=================================================================================
32. reverse button, showing text
// constants won't change. They're used here to
// set pin numbers:
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 off:
digitalWrite(ledPin, LOW);
Serial.println("button has been pushed, LED is off");
}
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
//=========================================
34. 100 random numbers between 0 and 9
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 100;
const int maxValue = 8;
const int minValue = 0;
int randomNumber;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
for (int i = 0; i < randomnumber =" random(minValue,">
//=========================================
35. 100 random numbers between 0 and 9 in listed order
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 100;
const int maxValue = 8;
const int minValue = 1;
int randomNumber;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
for (int i = 0; i < randomnumber =" random(minValue," size="3">//=========================================
36. 100 random numbers between 0 and 9 in listed order with average
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 10000;
const int maxValue = 8;
const int minValue = 1;
int randomNumber;
int timeDelay;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
Serial.flush();
float sum = 0;
float average = 0;
for (int i = 0; i < randomnumber =" random(minValue," average =" sum/maxNumber;" size="3">//=========================================
37. baud rates
min - 4800
max - 19200
//=========================================
38. reading LDR with button
int buttonPin2 = 2;
int photocellPin = 0;
int photoCellReading;
int buttonState;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
pinMode(buttonPin2, INPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
buttonState = digitalRead(buttonPin2);
if (buttonState == HIGH)
{
photoCellReading = analogRead(photocellPin);
Serial.println(photoCellReading);
delay(1000);
}
}
//=========================================
39. reading LDR with button and listed results
int buttonPin2 = 2;
int photocellPin = 0;
int photoCellReading;
int buttonState;
int buttonPushCount = 0;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
pinMode(buttonPin2, INPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
buttonState = digitalRead(buttonPin2);
if (buttonState == HIGH)
{
buttonPushCount ++;
photoCellReading = analogRead(photocellPin);
Serial.print("reading number ");
Serial.print(buttonPushCount);
Serial.print(" = ");
Serial.println(photoCellReading);
delay(1000);
}
}
//=========================================
54. data logging, no array or eeprom
int a = 0;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
readData();
while(run)
{
}
}
void readData()
{
for (int i = 0; i < value =" analogRead(readPin);" a =" a" a =" 0;" readpin =" 0;" run =" true;" i =" 0;" value =" intArray[i];" a =" a" i =" 0;" currvalue =" analogRead(readPin);">
int a = 1;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
storeData();
readData();
while(run)
{
}
}
void readData()
{
for (int i = 1; i <= 10; i++) { value = EEPROM.read(a); Serial.print(a); Serial.print("\t"); Serial.print(value); Serial.println(); a = a + 1; delay(500); } } void storeData() { for(int i = 1; i<=10; i++) { int currValue = analogRead(readPin); EEPROM.write(i, currValue); } delay(5000); } //========================================= 57. data logging with a "smallest value" function #include
int a = 1;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
storeData();
readData();
Serial.print("smallest value = ");
Serial.print(findSmallest());
while(run)
{
}
}
void readData()
{
for (int i = 1; i <= 10; i++) { value = EEPROM.read(a); Serial.print(a); Serial.print("\t"); Serial.print(value); Serial.println(); a = a + 1; delay(500); } } void storeData() { for(int i = 1; i<=10; i++) { int currValue = analogRead(readPin); EEPROM.write(i, currValue); } delay(5000); } int findSmallest() { int smallestValue = EEPROM.read(1); for(int i = 1; i <= 10; i++) { int tempValue = EEPROM.read(i); if (tempValue < smallestvalue =" tempValue;">
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
//=================================================================================
8. Quick Blink: Turns on for 10ms and off for one second continuously.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(10); // wait for 10ms
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
//=================================================================================
9. Slow Blink: turns on for one second and off for 10ms continuously.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(10); // wait for 10ms
}
//=================================================================================
10. Rapid Blink: The LED blinks rapidly turning off and on every 10ms.
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(10); // wait for 10ms
digitalWrite(ledPin, LOW); // set the LED off
delay(10); // wait for 10ms
}
My cut off point is three. I think it would differ from person to person seen as some people have better eye sight than others.
//=================================================================================
12. alternate blink
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(del); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(redLedPin, HIGH); // set the LED off
delay(del); // wait for a second
stop;
}
//=================================================================================
13.mostly on/off
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 250;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH);// set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(subdel); // wait for a second
digitalWrite(ledPin, LOW);// set the LED on
delay(50);
digitalWrite(ledPin, HIGH);// set the LED on
delay(subdel);
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(redLedPin, HIGH); // set the LED off
delay(del); // wait for a second
}
//=================================================================================
16.blink blink, wink
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH);// set the LED on
digitalWrite(redLedPin, LOW); // set the LED on
delay(subdel); // wait for a second
digitalWrite(ledPin, LOW);// set the LED on
delay(50);
digitalWrite(ledPin, HIGH);// set the LED on
delay(subdel);
digitalWrite(ledPin, LOW); // set the LED off
delay(subdel); // wait for a second
digitalWrite(redLedPin, HIGH); // set the LED off
delay(20); // wait for a second
digitalWrite(redLedPin, LOW); // set the LED off
delay(subdel); // wait for a second
}
//=================================================================================
17. blinks 5 times
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
18. blink random amount
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
19. increase rate of blinking
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
for (int i = 0; i <>
//=================================================================================
20. increase then decrease rate of blinking
int ledPin = 13; // LED connected to digital pin 13
int redLedPin = 12; // LED connected to digital pin 13
int del =500;
int subdel = 500;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
int i = 0;
long rand = random(1,10);
digitalWrite(ledPin, LOW); // set the LED on
while (i < i =" 0;">
//=================================================================================
21. output word, "blink"
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
Serial.println("blink");
delay(200); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(200); // wait for a second
}
//=================================================================================
22. output colour of LED that is on
*/
int redLedPin = 13;// LED connected to digital pin 13
int yellowLedPin = 12;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
Serial.begin(9600);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(redLedPin, HIGH); // set the LED on
Serial.println("red");
delay(200); // wait for a second
digitalWrite(redLedPin, LOW); // set the LED off
delay(200); // wait for a second
digitalWrite(yellowLedPin, HIGH); // set the LED on
Serial.println("yellow");
delay(200); // wait for a second
digitalWrite(yellowLedPin, LOW);// set the LED off
delay(200); // wait for a second
}
//=================================================================================
30. Button push
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 7.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave
modified 17 Jun 2009
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Button
*/
// constants won't change. They're used here to
// set pin numbers:
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);
}
}
//=================================================================================
31. reverse button
// constants won't change. They're used here to
// set pin numbers:
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);
}
}
//=================================================================================
32. reverse button, showing text
// constants won't change. They're used here to
// set pin numbers:
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 off:
digitalWrite(ledPin, LOW);
Serial.println("button has been pushed, LED is off");
}
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
//=========================================
34. 100 random numbers between 0 and 9
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 100;
const int maxValue = 8;
const int minValue = 0;
int randomNumber;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
for (int i = 0; i < randomnumber =" random(minValue,">
//=========================================
35. 100 random numbers between 0 and 9 in listed order
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 100;
const int maxValue = 8;
const int minValue = 1;
int randomNumber;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
for (int i = 0; i < randomnumber =" random(minValue," size="3">//=========================================
36. 100 random numbers between 0 and 9 in listed order with average
//creates 100 random numbers between 0 and 9 and outputs them
//to the screen.
const int maxNumber = 10000;
const int maxValue = 8;
const int minValue = 1;
int randomNumber;
int timeDelay;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
Serial.flush();
float sum = 0;
float average = 0;
for (int i = 0; i < randomnumber =" random(minValue," average =" sum/maxNumber;" size="3">//=========================================
37. baud rates
min - 4800
max - 19200
//=========================================
38. reading LDR with button
int buttonPin2 = 2;
int photocellPin = 0;
int photoCellReading;
int buttonState;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
pinMode(buttonPin2, INPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
buttonState = digitalRead(buttonPin2);
if (buttonState == HIGH)
{
photoCellReading = analogRead(photocellPin);
Serial.println(photoCellReading);
delay(1000);
}
}
//=========================================
39. reading LDR with button and listed results
int buttonPin2 = 2;
int photocellPin = 0;
int photoCellReading;
int buttonState;
int buttonPushCount = 0;
// The setup() method runs once, when the sketch starts
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
pinMode(buttonPin2, INPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
buttonState = digitalRead(buttonPin2);
if (buttonState == HIGH)
{
buttonPushCount ++;
photoCellReading = analogRead(photocellPin);
Serial.print("reading number ");
Serial.print(buttonPushCount);
Serial.print(" = ");
Serial.println(photoCellReading);
delay(1000);
}
}
//=========================================
54. data logging, no array or eeprom
int a = 0;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
readData();
while(run)
{
}
}
void readData()
{
for (int i = 0; i < value =" analogRead(readPin);" a =" a" a =" 0;" readpin =" 0;" run =" true;" i =" 0;" value =" intArray[i];" a =" a" i =" 0;" currvalue =" analogRead(readPin);">
int a = 1;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
storeData();
readData();
while(run)
{
}
}
void readData()
{
for (int i = 1; i <= 10; i++) { value = EEPROM.read(a); Serial.print(a); Serial.print("\t"); Serial.print(value); Serial.println(); a = a + 1; delay(500); } } void storeData() { for(int i = 1; i<=10; i++) { int currValue = analogRead(readPin); EEPROM.write(i, currValue); } delay(5000); } //========================================= 57. data logging with a "smallest value" function #include
int a = 1;
int value;
int readPin = 0;
boolean run = true;
void setup()
{
Serial.begin(9600);
pinMode(readPin, INPUT);
}
void loop()
{
storeData();
readData();
Serial.print("smallest value = ");
Serial.print(findSmallest());
while(run)
{
}
}
void readData()
{
for (int i = 1; i <= 10; i++) { value = EEPROM.read(a); Serial.print(a); Serial.print("\t"); Serial.print(value); Serial.println(); a = a + 1; delay(500); } } void storeData() { for(int i = 1; i<=10; i++) { int currValue = analogRead(readPin); EEPROM.write(i, currValue); } delay(5000); } int findSmallest() { int smallestValue = EEPROM.read(1); for(int i = 1; i <= 10; i++) { int tempValue = EEPROM.read(i); if (tempValue < smallestvalue =" tempValue;">
Thursday, March 18, 2010
40, 41. YaBB
40. Forum Post: III Arduino Contest
The fact that you can win money by creating enjoyable projects sounds very interesting. Even though I'm not anywhere close to that level of expertise, it's nice to know that there is a little money involved if I ever decided to become a competitive "arduino maker".
Link:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264155114
42. Write a short list of rules for a bulletin board like YABB. Watch some thread over two weeks and be ready to make a contribution - ???
The fact that you can win money by creating enjoyable projects sounds very interesting. Even though I'm not anywhere close to that level of expertise, it's nice to know that there is a little money involved if I ever decided to become a competitive "arduino maker".
Link:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264155114
42. Write a short list of rules for a bulletin board like YABB. Watch some thread over two weeks and be ready to make a contribution - ???
Sunday, March 14, 2010
Subscribe to:
Posts (Atom)