Friday, May 7, 2010

Missed Tasks from the 50

Tasks 15 (not on notices blog?), 29, 48 and 50 are not completed.

Tasks 2, 3, 6

Task 2: Put Blog link into moodle


Task 3: Fill in Details on Moodle Wiki
Moodle Profile

Task 6: Make a sketches folder

Thursday, May 6, 2010

How many Arduino's? (Task 23)


The Arduino Mega is a board that is code compatible with Arduino Duemilanove. It runs an Atmega1280 (instead of a 168 or 328). As a result it has a greater number of digital pins (54 vs 14), PWM pins (14 vs 6) and analog inputs (16 vs 6).

Baud Rate (Task 37)

The highest rate without ending up with trash output is 19200 baud

Arduino Key Works (Task 25, 33)

setup(): This is a loop that only runs once when the arduino is first powered on (or reset). In this loop settings like pinMode() are specified and variables are set/reset.

loop(): This is where the main portion of the program is. This is a constant loop that begins again immediately after finishing.

analogRead(): This is used to pull values from the analogue pins. The pin number goes in the brackets (analogRead(2)). This is mostly done with sensors that can have a wide range of values (usually based off resistance e.g. LDR, Temperature sensor). The value read is always between 0 and 1023 depending on resistance.

Serial.print(): This is to write what ever is in the brackets out to a serial monitor. Variables can simply be typed in i.e. Serial.print(count) but if you wish to write out simple text it must be within quotation marks i.e. Serial.print("Text Here"). Anything in the brackets will be added to the previous line (unless the previous line was written with Serial.println()).

Serial.println(): Same as above except the message sent will end the current line.

pinMode(): This is used to set whether a digital pin is an input or an output (pinMode(13,INPUT) sets pin 13 as a digital input where as pinMode(13,OUTPUT) is the opposite). This is typically only used in setup() but can also be used in the main loop().

digitalRead(): This is used to check a sensor or button on a digital pin. This will either return HIGH or LOW. An example of how digital read is used: state = digitalRead(13).

Arduino Forum Rules (Task 42)

- Be polite
- Do not post false/inaccurate information
- No abusing/harassing/threatening behavior towards others
- Treat everyone with respect

Task 46, 47,49

By separating the code in the previous post into the send/recieve roles you can send pulses between two ardunio boards.

Sender Code:
void setup(){
pinMode(13,OUTPUT);
}

void loop(){
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}

This code will pulse the IR transmitter between on and off with a ~500ms pause at each state;

Receiver Code:
int reading;

void setup(){
pinMode(13,INPUT);
Serial.begin(9600);
}

void loop(){
reading = digitalRead(13);
if (reading == HIGH){
Serial.println("High");
}
else
{
Serial.println("Low");
}
}

The receiver will either print High or Low depending on what the other board sent.

Task 49:

Sender Code:
int count = 0;

void setup(){
pinMode(13,OUTPUT);
}

void loop(){
for (int i = 0; i < 1001; i ++){
digitalWrite(13,HIGH);
delay(1);
digitalWrite(13,LOW);
delay(1);
}
}

Receiver Code:
int count = 0;

void setup(){
pinMode(13,INPUT);
Serial.begin(9600);
}

void loop(){
for (int i = 0; i < 1001; i ++){
reading = digitalRead(13);
if (reading == HIGH){
Serial.println("High");
count = count + 1;
}
else
{
Serial.println("Low");
}
}
Serial.print(count);
Serial.println(" of 1000 recieved");
}

Infrared Send/Recieve (Task 45)

I set this up to run on a single arduino board (pin 13 being an input and 12 being output) but the code can easily be adapted so that one board can act as a sender and another as a receiver.

int infra;
int count = 0;

void setup(){
pinMode(13,INPUT);
pinMode(12,OUTPUT);
Serial.begin(9600);
}

void loop(){
for (int i = 0; i < 21; i ++){
digitalWrite(12,HIGH);
infra = digitalRead(13);
delay(500);

if (infra == HIGH){
count = count + 1;
Serial.println(count);
}
else{
Serial.print(count);
Serial.println(" Blocked");
digitalWrite(12,LOW);
}
}
Serial.println("Finished");
delay(1000);
}

Class Presentation (Task 44)

Gave a presentation to the class on Shift Registers (namely the 74HC164)

Project Sites (Task 43)

Instructables

Instructables is prob the best site I have found as the creator of the projects have a run down of how they created their project as well as source code etc.

Make:

This site has a lot of project but some are thin on details on how they are done but they also have a few tutorials.

Hack A Day

This site has a number of projects from various sources (including the two above at times) and for various electronic and software platforms.

Practical Arduino

This site is similar to Hack A Day in that thet list projects from other sites except this site is purely arduino projects.

Register for YABB forum (Task 41)

Serial IP Library (Task 40)

Serial IP Library allows communication with an arduino via a network connection without a network shield. This is quite good as it could possibly reduce the cost of the projects that require a network connection.