Sunday, April 11, 2010

Arduino Pro:


This board is designed for advanced users who want to leave a board embedded in a project: it's cheaper than a Diecimila and easily powered by a battery, but requires additional components and assembly.


The Arduino Pro is a microcontroller board based on the ATmega168 (datasheet) or ATmega328 (datasheet). The Pro comes in both 3.3V / 8 MHz and 5V / 16 MHz versions. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a battery power jack, a power switch, a reset button, and holes for mounting a power jack, an ICSP header, and pin headers. A six pin header can be connected to an FTDI cable or Sparkfun breakout board to provide USB power and communication to the board.

The Arduino Pro is intended for semi-permanent installation in objects or exhibitions. The board comes without pre-mounted headers, allowing the use of various types of connectors or direct soldering of wires. The pin layout is compatible with Arduino shields. The 3.3V versions of the Pro can be powered with a battery.

The Arduino Pro was designed and manufactured by SparkFun Electronics.

This information was taken from: http://arduino.cc/en/Main/ArduinoBoardPro

Thursday, March 18, 2010

Infrared research:

http://www.youtube.com/watch?v=P1pGKZzYbUk

http://www.rtfa.net/tag/arduino

http://robot-overlord.blogspot.com/2009/04/simple-ir-detection-circuit-tutorial.html

Interesting Websites for ideas...


1) http://www.instructables.com/




2) http://www.arduino.cc/playground/Projects/ArduinoUsers




3)www.youtube.com




IR Tailgate Buddy: Robotic Power Wheels Vehicle
http://www.youtube.com/watch?v=Pbob9y5NMQ0



4) http://www.coolcircuit.com/




More tasks...

34) Write a program to generate 100 random numbers between 0 and 9 to the screen.
35) Same as above but this time put your outputs in a numbered list like this:
1. 7
2. 4
3. 9 etc til you get to 100.
36) Same but also output the average (mean) of the 100 numbers with a suitable message.
37) Same but this time see if you can drive the baud rate up as far as possible before the output data gets scrambled. Also, what is the slowest speed the Arduino serail will ouitput at? Write your findings in your blog.
38) Write a program to output the value of your LDR whenever you press the button.
39) Same as 38 but this time write your output like this :
Reading number 1 is 345
Reading number 2 is 123
Reading number 3 is 876 etc...

Next topic will be on reporting back about the YABB board.

Thursday, March 11, 2010

LED project...


My plan for the LED project was to create an electronic dice. I found an example on the internet and tryed to base mine off that. To get the dice to act realisticly, the lights formation would have to be randomized. There was a page on the arduino website which was really useful = http://www.arduino.cc/en/Reference/Random Then i worked out the formation and how it would work. The LEDs would be grouped so that when the random number was called, each LED would not need to be callled individually. The groups were 1, 2, 3 & 4. Code:
int pinLeds1 = 10; //2 corner LEDs
int pinLeds2 = 9; //2 outer middle LEDs
int pinLeds3 = 8; //Other 2 corner LEDs
int pinLed4 = 7; //middle LED
int buttonPin = 6; //Button input reader
int buttonState; //On or off (HIGH/LOW)
int rGen; //random generator variable
int time = 4000; //hold for 4 seconds.

void setup () {
pinMode (pinLeds1, OUTPUT);
pinMode (pinLeds2, OUTPUT);
pinMode (pinLeds3, OUTPUT);
pinMode (pinLed4, OUTPUT);
pinMode (buttonPin, INPUT);
randomSeed(analogRead(0));
}

void loop() {
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH){ //if the button has been pressed
rGen = random(1, 7); //rGen=random number between 1 and 6.

if (rGen == 1){ //light up centre light.
digitalWrite (pinLed4, HIGH);
delay (time);
}

if (rGen == 2){ //Light up 2 corner lights.
digitalWrite (pinLeds1, HIGH); delay (time);
}
if (rGen == 3){ //Light up 2 corner and middle lights.
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (rGen == 4){ //Light up all 4 corners.
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}

if (rGen == 5){ //Light up all 4 corners plus middle light.
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (rGen == 6){ //light up all except middle.
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds2, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}
} //else if not pressed and time has ended turn all off.
digitalWrite (pinLeds1, LOW);
digitalWrite (pinLeds2, LOW);
digitalWrite (pinLeds3, LOW);
digitalWrite (pinLed4, LOW);
}//end.

At run time, something was not right and nothing lit up at all. Because I was basing mine on one i found on the internet, i went back and looked through what the example had. The bread board i was using was a completely different set up. The example had a ground row that all the resistors were connected too. Mine did not. After checking all the wires and LEDs were connected in the right pattern and formation, I went to check through my code. As this is very low level code it would have been easy to spot any errors, but there appeared to be none. With no other resources avalible to me, I had to show what I had created in class, even though it did not work.

After borrowing another bread board from Adam which had a ground row in it, i was able to re wire up my project and test it! My excitement faded when only a few of the LED lit up, but i quickly realised it was because several of my resistors were ones that I found lying around home, and were not the right level to allow much power to the LEDs. I replaced my ones from home with 7 X 220 ohm resistors that I got from Ashley, reset the Arduino, uploaded the code once again and this time SUCCESS!!! The LEDs light up perfectly and in the formation that was originally intended.

So my main issues for this project were: Lack of basic knowledge (this stuff is all still quite new to me), lack of correct equipment, and fiddly small components!!! (My eyes hurt so much). Other than this, I am very pleased with the final outcome.

Even if all the LEDs are green :P


Sunday, March 7, 2010

Task 32:

32) Same as 30 but also output the state of the button and the led to the serial screen. I might see on one line then: "button pressed ....led off".

if (buttonState == HIGH) {
Serial.println("button pressed ....led off");

same as before, only i'm adding a few more words.

Task 31:

31) Change the above program by reversing the the way the led goes on/off when the button is pushed/not pushed. Publish your program with a suitable comment.

This is the same as the last one, the only code that needed to be changed was the HIGH/LOW states in the if statement.

if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, LOW);
}
else {
// turn LED off:
digitalWrite(ledPin, HIGH);
}
}