The plan to control the brightness of the LED.
Componets:
Arduino Board
Mini Bread board
Some Jump lead wires to connect it all up.
3 LEDs (Reg, Green, Blue)
3 resistors.
Based on the Fading example on the Arduino site, and provided in the Arduino development environment, I wired up the 3 LEDs to the Arduino board. Then modified it to control 3 LEDs.
To get a bit more cleaver I wanted to control the light from the computer, the Dimmer example provided the basics for the implementation from the Arduino board side of things.
For the coding on the laptop I decided to implement this in Java. The reason for this is Java is something I know my way around well. With the Arduno code which is based on C/C++ I am just winging it at the moment.
If this is the first time you want to communicate over a serial port in Java code you'll need to install some Operating System dependant libraries. This surprised me a bit, but found the following link, which provided the info required. Go with the rxtxSerial libraries not SUN's javax.comm package, its not good gave me some grief.
The link for installing the libraries also had some sample code for implementation which I happily blagged and modified in order to knock up a bit of Java to display a JColorChooser component, hooking the code to send the selected colours RGB values to the Aruino to change the colour of each of the LEDs.
After some playing/searching/thinking decided on a go with the format o #RRGGBB, with colours represented as HEX, and pad if the value is less than 10, to get a consistent 2 digits for each colour value.
On the Arduino side the following function takes care of reading the data in. The serInStr array and dataLength, are sized to the expected 7 so that takes care of reading a complete value each time.
//read a string from the serial and store it in an array
int readSerialString () {
int i=0;
if(!Serial.available())
{
//Serial.println("No Data");
return -1;
}
while (Serial.available() && i < dataLength)
{
int c = Serial.read();
serInStr[i++] = c;
}
Serial.println(serInStr);
return i;
}
Works really well so am pleased with progress.
Next on the the scary bit, trying not to cook the accelerometer. LEDs about £1 not bothered if i cook them, the accelerometer £27, that would annoy me somewhat.
Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts
Wednesday, 19 November 2008
Tuesday, 18 November 2008
The postman only knocks once...
The doorbell is broken!
Was expecting the delivery so was keeping an eye out, saw the postman on his way up the other side of the street so was halfway down the stairs when he knocked.
The package was surprisingly small, well not so if I had put 2 and 2 together, the image from the web site the specifications that said it is 75x55mm, the accelerometer on the breakout board 20x20mm, the chip itself 5x5mm, glad I didn't think I would 'have a go' a soldering that up myself.
I had spent a bit of time looking around the Arduino site, http://www.arduino.cc, and was surprised to find installation instructions for OpenSUSE Linux, that is rare! And find I am jumping through hoops to get things working following some other flavour of Linux's usually Ubuntu based instructions that just don't work the same.
Anyway after extracting the Adruino development environment, installing the following dependencies,
Was expecting the delivery so was keeping an eye out, saw the postman on his way up the other side of the street so was halfway down the stairs when he knocked.
The package was surprisingly small, well not so if I had put 2 and 2 together, the image from the web site the specifications that said it is 75x55mm, the accelerometer on the breakout board 20x20mm, the chip itself 5x5mm, glad I didn't think I would 'have a go' a soldering that up myself.
I had spent a bit of time looking around the Arduino site, http://www.arduino.cc, and was surprised to find installation instructions for OpenSUSE Linux, that is rare! And find I am jumping through hoops to get things working following some other flavour of Linux's usually Ubuntu based instructions that just don't work the same.
Anyway after extracting the Adruino development environment, installing the following dependencies,
- avrdude
- avr-libc
- cross-avr-binutils
- cross-avr-gcc
One stop shop
In my comfort zone buying things I know about, from sites i have used before, I quite like the 'magic' of internet shopping. This is a completely different kettle of fish, don't know really what I am buying and looking on all new sites for the bits.
While I only wanted a couple of main bits I wanted to get them somewhere that had all the bits I would need for the project, I am always a bit dubious about handing over my my credit card details to a new web site, then the wait and wonder if anything will turn up. While the internet banking gets frequent random spot checks on the Credit Card balance.
Turns out all accelerometers are not created equal, there are a few quite options to choose from, I decided on the LIS3LV02DQ Triple Axis Accelerometer mounted on a breakout board.
http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=36&products_id=135 At close to 30 quid not the cheapest option, but was thinking it would be more versatile if required for some yet to be dreamed up future project.
Went to local(ish) electronics shop to get a few bits and bobs,
Jump leads
Red/Green/Blue LEDs - I want as one unit but these are cheap and will do for the first stage.
3x 1KOhm Resisters (I think)
Header pins to solder to the breakout board of the accelerometer.
And ordered the Arduino Diecimila and Accelerometer, and mini board from http://www.coolcomponents.co.uk/catalog/.
The other site I found very useful was http://www.sparkfun.com/ is has a wider range of components, but opted for Cool Components as it is UK based.
Then in for the down side to Internet Shopping for physical objects... the wait
While I only wanted a couple of main bits I wanted to get them somewhere that had all the bits I would need for the project, I am always a bit dubious about handing over my my credit card details to a new web site, then the wait and wonder if anything will turn up. While the internet banking gets frequent random spot checks on the Credit Card balance.
Turns out all accelerometers are not created equal, there are a few quite options to choose from, I decided on the LIS3LV02DQ Triple Axis Accelerometer mounted on a breakout board.
http://www.coolcomponents.co.uk/catalog/product_info.php?cPath=36&products_id=135 At close to 30 quid not the cheapest option, but was thinking it would be more versatile if required for some yet to be dreamed up future project.
Went to local(ish) electronics shop to get a few bits and bobs,
Jump leads
Red/Green/Blue LEDs - I want as one unit but these are cheap and will do for the first stage.
3x 1KOhm Resisters (I think)
Header pins to solder to the breakout board of the accelerometer.
And ordered the Arduino Diecimila and Accelerometer, and mini board from http://www.coolcomponents.co.uk/catalog/.
The other site I found very useful was http://www.sparkfun.com/ is has a wider range of components, but opted for Cool Components as it is UK based.
Then in for the down side to Internet Shopping for physical objects... the wait
Where it started...
The goal of this project:
Think, holding a Rubik's Cube, whatever side is facing up, is the colour the lamp on the other side of the room will change to. As the cube is rotated the light will change.
The plan: To build this using an Arduino Diecimila open source board(x 2), RGB LEDs, 3 Axis Accelerometer, and wirless transmitter/reciever.
Floating around in the back of my head for a while has been the idea to play with intelligent or automated control systems, without a any specific plan or project in mind.
While fossicking around the internet a while back I came across a project on the instructables.com web site (had not heard of this before), which I looked at and thought was pretty cool, it showed a RGB LED being controlled wirelessly using an Accelerometer to control the colour, see here. I was holding a Rubik's cube at the time, and was thinking how cool would it be to rotate the cube so that the colour facing up would be the colour the LED would emit and while rotating, would gradually change between these colours.
One of the components was was an 'Arduino wee' Searching for this I found discovered the Arduino site
and the 'Arduino Diecimila' an Open Source electronics development platform,
A few days passed and the idea kept growing on me and the 'thats pretty cool' factor hadn't waned. So I went shopping for the bits, as this is something I know very little (nothing) about I decided on a run before walk approach, so I only ordered a couple of core components, the 'Arduino Diecimila' board, and the Accelerometer.
I started this a week or so ago, so will post a couple in quick succession in line with my progress, rather than one huge post.
So it begins...
Think, holding a Rubik's Cube, whatever side is facing up, is the colour the lamp on the other side of the room will change to. As the cube is rotated the light will change.
The plan: To build this using an Arduino Diecimila open source board(x 2), RGB LEDs, 3 Axis Accelerometer, and wirless transmitter/reciever.
Floating around in the back of my head for a while has been the idea to play with intelligent or automated control systems, without a any specific plan or project in mind.
While fossicking around the internet a while back I came across a project on the instructables.com web site (had not heard of this before), which I looked at and thought was pretty cool, it showed a RGB LED being controlled wirelessly using an Accelerometer to control the colour, see here. I was holding a Rubik's cube at the time, and was thinking how cool would it be to rotate the cube so that the colour facing up would be the colour the LED would emit and while rotating, would gradually change between these colours.
One of the components was was an 'Arduino wee' Searching for this I found discovered the Arduino site
and the 'Arduino Diecimila' an Open Source electronics development platform,
A few days passed and the idea kept growing on me and the 'thats pretty cool' factor hadn't waned. So I went shopping for the bits, as this is something I know very little (nothing) about I decided on a run before walk approach, so I only ordered a couple of core components, the 'Arduino Diecimila' board, and the Accelerometer.
I started this a week or so ago, so will post a couple in quick succession in line with my progress, rather than one huge post.
So it begins...
Subscribe to:
Posts (Atom)