Aaron DaMommio: husband, father, writer, juggler, and expert washer of dishes. "DaMommio" rhymes with "the Romeo", as in "my parents told me they thought about naming me Romeo DaMommio, and I believed them, when I was ten."
Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts
Thursday, February 25, 2010
Arduino electric bricks
These components make it possible to hook up stuff to an Arduino board without doing any soldering. It's an interesting option, especially for, say, a hacker who can handle a little code but isn't interested in soldering.
Monday, November 02, 2009
Pluggable sensors for Arduino

MakerShed is now offering a product that allows you to plug various sensors and a display into an Arduino, without soldering. This is a great idea, making the Arduino more like a cheap open-source Lego NXT.
The $50 price for the set isn't bad, either.
I've still got a nice Arduino-based game kit lying around. Haven't spent time on the hacking lately.
Monday, May 11, 2009
Arduino LED control with potentiometer
Some friends were nice enough to give me a Fry's gift card for my birthday. I hate how Fry's is always tempting you in the door with prices that turn out to be based on mail-back rebates that don't always go your way. But this card was a godsend when I needed more components to use to play with my Arduino board. So I got a couple of potentiometers and some LEDs and resistors and I'm in business.
That same evening, I wired up 4 resistors and a potentiometer on the breadboard. I had each led connected to a different digital IO pin -- pins 9-12 -- and the pot is on analog pin 2.
Then I wrote some code that works like this:
- It turns off all the LEDS
- It reads the pot value (range of 0 to 1023)
- If the pot value is more than 0, it lights LED1.
- If the value is more than 1/4 the total, it lights LED2. More than half, light LED3; more than 3/4, light LED4.
The result is a gadget that shows between one and four LEDs lit, depending on how far you dial the potentiometer. That's no big deal, the important part is that I was, that same evening, able to demonstrate using the pot to control something.
Here's the code I used. I'm also sending the pot value back to the computer through the serial link, but I'm doing something wrong there, it's getting random characters....I haven't figured out how to properly convert the int value from the pot into a string. I'm realizing now that the Arduino/Processing language is basically C, and C has lousy built-in string support, and I'm used to scripting languages that are good at strings. Of course, an Arduino doesn't even do floating point arithmetic; it makes sense to keep the code simple and low-level for its purposes.
That same evening, I wired up 4 resistors and a potentiometer on the breadboard. I had each led connected to a different digital IO pin -- pins 9-12 -- and the pot is on analog pin 2.
Then I wrote some code that works like this:
- It turns off all the LEDS
- It reads the pot value (range of 0 to 1023)
- If the pot value is more than 0, it lights LED1.
- If the value is more than 1/4 the total, it lights LED2. More than half, light LED3; more than 3/4, light LED4.
The result is a gadget that shows between one and four LEDs lit, depending on how far you dial the potentiometer. That's no big deal, the important part is that I was, that same evening, able to demonstrate using the pot to control something.
Here's the code I used. I'm also sending the pot value back to the computer through the serial link, but I'm doing something wrong there, it's getting random characters....I haven't figured out how to properly convert the int value from the pot into a string. I'm realizing now that the Arduino/Processing language is basically C, and C has lousy built-in string support, and I'm used to scripting languages that are good at strings. Of course, an Arduino doesn't even do floating point arithmetic; it makes sense to keep the code simple and low-level for its purposes.
/* Several LEDS
light, and control, several leds
1. Make 4 leds blink in alternation
2. Read ANY value via serial, from ARD
3. Hook up a pot, read its value
made from Blink without Delay
*
* Turns on and off a light emitting diode(LED) connected to a digital
* pin, without using the delay() function. This means that other code
* can run at the same time without being interrupted by the LED code.
*
* http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
*/
int ledPin1 = 10;
int ledPin2 = 11;
int ledPin3 = 12;
int ledPin4 = 9;
int value = LOW; // previous value of the LED
int oppvalue = HIGH; // opposite value
long previousMillis = 0; // will store last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)
int potPin = 2; // analog pin the pot is on
int potVal = 0; // initial analog value
char potStr[5];
void setup()
{
pinMode(ledPin1, OUTPUT); // sets the digital pin as output
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
// Start by turning off all the LEDs
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
potVal = analogRead(potPin); // read the value from the sensor
// this should be btw 0 and 1023
itoa(potVal,potStr,10);
// standard function, takes int, string, and then BASE = base 10 math
Serial.print(potStr);
// Not quite working....returns chars but they aren't numbers like I expected.
if (potVal > 0) {
digitalWrite(ledPin1, HIGH);
}
if (potVal > 255) {
digitalWrite(ledPin2, HIGH);
}
if (potVal > 512) {
digitalWrite(ledPin3, HIGH);
}
if (potVal > 767) {
digitalWrite(ledPin4, HIGH);
}
}
Wednesday, May 06, 2009
My first arduino: a DC Boarduino kit
I built my first through-hole soldering kit this weekend, and also my first arduino. I'm darn happy about it:
I've already had some fun playing with parts from my junk box. I think this'll make it possible to make lots of things out of junk.
On the other hand, I had intended to build most of the projects from Making Things Talk. However, the components used for some of the coolest projects in that books are pretty expensive -- bluetooth modules that cost $60, GPS modules, wireless networking modules. Unfortunately, it looks like the sort of modules that are easy to interface to a board are expensive, even as the consumer versions of such things become super cheap. But since an arduino can speak USB, maybe I can interface to some castoff parts that way.
(When I sat down to write this post, I decided there were probably lots of posts out there about people's first arduino boards. And there are.)
- I built this thing the same weekend that it came in the mail. My usual practice would be to let a kit like this sit and ferment for weeks.
- My first kit worked almost the first time! When I was building it, I got done, applied power, and it wouldn't work. And then I saw that I had one resistor left over. And I had to drill a hole through some solder that I'd accidentally allowed to fill a hole for that resistor, while maneuvering around all the other components. On the other hand, NONE of my neophyte solder connections were bad, so after I installed the missing piece, it worked great. This is like the principle of letting a kid win the first time they play a game. If I'd broken this first kit, I worry that I wouldn't stick with the hobby.
- It loads code pretty fast.
- My kids seem interested in learning to solder and work with electronics. This is going to be fun.
I've already had some fun playing with parts from my junk box. I think this'll make it possible to make lots of things out of junk.
On the other hand, I had intended to build most of the projects from Making Things Talk. However, the components used for some of the coolest projects in that books are pretty expensive -- bluetooth modules that cost $60, GPS modules, wireless networking modules. Unfortunately, it looks like the sort of modules that are easy to interface to a board are expensive, even as the consumer versions of such things become super cheap. But since an arduino can speak USB, maybe I can interface to some castoff parts that way.
(When I sat down to write this post, I decided there were probably lots of posts out there about people's first arduino boards. And there are.)
Subscribe to:
Posts (Atom)