
Monday, March 22, 2010
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() {
}
Subscribe to:
Posts (Atom)
