One of the nicest things about most micro controllers is their low power requirements, thus giving one a large range of possibilities powered by 5 volts. Since this is such a low power consumption, we are given to a wide range of methods to power and/or charge our power supply.
The first and perhaps easiest way that jumps to mind, is using a small solar panel to recharge a 9 volt battery used to power the Arduino.
I came across a wonderful Instructable by p2man that illustrates the basics on how to setup a solar panel charging circuit.
I can see this being a great way to power self contained devices like weather sensors or other such devices. This way they can just sit and collect data, or do their task and we don’t need to remember to replace the battery. Thus a solar powered Arduino project can be left to do it’s own thing… SET IT, and FORGET IT!
Read p2man’s Instructable on the Self Sufficient Arduino
The color selector is 3 linear pots that control the rgb values of a square in a window. The window also displays the rgb values. Kinda simple to make, I reused a lot of code from the etch-a-sketch sketch. I am working on my processing book, so my projects should get better.
The dot in the red pick, is me not being able to use a mouse properly, the lines on the text seem to be a problem with the font I picked.
/*
Color Selector
Takes 3 pots hooked up to analog 0,1,2 and uses them for the red green blue
values of a square.
Also displays the number for each color
*/
import processing.serial.*;
Serial myPort;
String inString; // Input string from serial port:
String letter;
int number;
String numberS;
int redNum, greenNum, blueNum;
int x = 300; //somewhere around 200 or 300
int y = 300;
int lf = 10;
PFont font;
void setup() {
size(x, y);
//you may have to change the serial port
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf);
background(0);
font = loadFont("aakar-medium-20.vlw"); //make your own font
}
void draw() {
background(0);
textFont(font);
fill(255, 0, 0);
text(redNum, 10,30);
fill(0, 255, 0);
text(greenNum, 70,30);
fill(0, 0, 255);
text(blueNum, 130,30);
fill(redNum, greenNum, blueNum);
rect(0,50,x,y);
}
void serialEvent(Serial p) {
inString = (myPort.readString());
letter = inString.substring(0, 1);
numberS = inString.substring(2);
numberS = trim(numberS);
number = Integer.parseInt(numberS); //I could have combined a bit of this, but this code is for learning
if(letter.equals("R") == true) {
redNum = number;
}
if(letter.equals("G") == true) {
greenNum = number;
}
if(letter.equals("B") == true) {
blueNum = number;
}
}
/*Arduino Code
int bluePin = 2; //analog pin for right hand knob
int greenPin = 1; //analog pin for left hand knob
int redPin = 0; //analog pin for center knob (width)
//Info for Serial Data
int id_1 = 'R';
int id_2 = 'G';
int id_3 = 'B';
int space = ' ';
void setup()
{
pinMode(redPin, INPUT);
pinMode(greenPin, INPUT);
pinMode(bluePin, INPUT);
Serial.begin(9600);
}
void loop()
{
int redNum = analogRead(redPin);
int greenNum = analogRead(greenPin);
int blueNum = analogRead(bluePin);
//the arduino will read from 0 to 1024 on teh analog pins, so we divide that by 4
redNum = redNum / 4;
greenNum = greenNum / 4;
blueNum = blueNum / 4;
printByte(id_1);
printByte(space);
printInteger(redNum); printByte(10);
printByte(id_2);
printByte(space);
printInteger(greenNum); printByte(10);
printByte(id_3);
printByte(space);
printInteger(blueNum); printByte(10);
delay(10);
}
*/
Several of my favorite Arduino/Freeduino stores have sent us in some giveaways for the con. We are not sure how we are going to be giving things out, as most are kits, I think we will be giving them out during our talk and during the tutorials going on during the day. Maybe get a few teams together during the talk and give them each a board to put together and do a project off of. Then give more coolness away for the team that makes the coolest stuff, I guess I need to bring a big box of parts.
Paul from Modern Device sent in 3 rBBB’s, 2 P4 RS232 to TTL Serial Adapter Kits, 2 LCD117 Serial LCD Boards, 2 16×2 blue LCD’s and a Serial Cable.
I saw this floating around the web and wanted to share with all. Its free printable graph paper that allows you to scan your drawing without picking up the graph lines with your scanner.
I had seen some similar things on the internet, but I wanted to make my own. I took 3 pots hooked up to analog inputs on my Arduino and then sent a serial connection that looked like this:
X56
Y378
Z5
X68
Y378
Z6
Using Processing, I read that stream and displayed the variables on the screen. So you can change the horizontal, vertical, and size of the drawing dot. I also included a grey dot in the middle of the big dot, so you have a reference of where your dot is. This code isn’t fancy and allows for many upgrades. Most importantly, I am not redrawing the background to allow for the green dots to draw lines, don’t worry, I left a few comments to help you out.
All you need is a duino, 3 pots, processing, and the arduino ide.
/*
Duino Etch-a-Sketch
by droops
http://dailyduino.com
I used sources from all over the internet, so thanks for the code, please use mine
Sometimes it doesnt run and will dump out an error, just try to run it again before
you get all crazy and start throwing things
*/
import processing.serial.*;
Serial myPort;
String inString; // Input string from serial port:
String letter;
int number;
String numberS;
int x, y, z;
int redColor = 12;
int blueColor = 170;
int greenColor = 21;
int lf = 10;
void setup() {
size(512, 512);
//you may have to change the serial port
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(lf);
background(0);
}
void draw() {
// background(0); //uncomment this to just have a floating ball
stroke(redColor, blueColor, greenColor); //changing colors are for version 2
fill(redColor, blueColor, greenColor);
smooth();
ellipse(x, y, z, z); //this is the circle
stroke(255); //color of point
point(x, y); //point inside circle, comment this to remove
}
void serialEvent(Serial p) {
inString = (myPort.readString());
letter = inString.substring(0, 1);
numberS = inString.substring(2);
numberS = trim(numberS);
number = Integer.parseInt(numberS); //I could have combined a bit of this, but this code is for learning
if(letter.equals("X") == true) {
x = number;
}
if(letter.equals("Y") == true) {
y = number;
}
if(letter.equals("Z") == true) {
z = number;
}
}
/*
//Arduino Code for Etch-a-Sketch
int rightPin = 3; //analog pin for right hand knob
int leftPin = 2; //analog pin for left hand knob
int widthPin = 1; //analog pin for center knob (width)
//Info for Serial Data
int id_1 = 'X';
int id_2 = 'Y';
int id_3 = 'Z';
int space = ' ';
void setup()
{
pinMode(rightPin, INPUT);
pinMode(leftPin, INPUT);
pinMode(widthPin, INPUT);
Serial.begin(9600);
}
void loop()
{
int rightNum = analogRead(rightPin);
int leftNum = analogRead(leftPin);
int widthNum = analogRead(widthPin);
//the arduino will read from 0 to 1024 on teh analog pins, so we divide that by 2
//to fit in the 512x512 screen
//by doing this simple math on the arduino, it may make things faster
rightNum = rightNum / 2;
leftNum = leftNum / 2;
//we divide the widthNum by 50 so that the elipse can be a bit bigger, play with this number
widthNum = widthNum / 50;
printByte(id_1);
printByte(space);
printInteger(rightNum); printByte(10);
printByte(id_2);
printByte(space);
printInteger(leftNum); printByte(10);
printByte(id_3);
printByte(space);
printInteger(widthNum); printByte(10);
delay(10);
}
*/
Morgellon and I will be talking about “The Extraordinary Journey from Fundamental Electronics to Fabulous Enchanted Systems with Arduino’s and Magical Potions” at PN 12 http://phreaknic.info/pn12/
droops and Morgellon will take you from basic electronics to building embedded systems. Learn how to build a standalone RFID tag reader with a fancy LCD display or your own oscilloscope or childrens
toys that speak to you or how to solar power a geothermal heat pump. There may even be some giveaways and contests. Magical Potions will be consumed but not provided.
Code will be posted on the blog as we get it availible, hopefully all will be done before the con.
First off, Morgellon went to school for this kind of stuff and has a fancy degree in electronics wizardry or something like that. I on the other hand, am reading books on processing, embedded electronics, microcontrolers and basic electronics.
Everyone says use Eagle, here is a tutorial, learn Eagle…
I have been working on that and have failed thus far, it seems my mind can’t wrap itself around how to lay things out and even what things are and how they are connected. I opened a bunch of Ladyada’s PCB designs and have succeeded only in removing things and moving things.
This is where Fritzing comes along. There is a library where things look like what they are and there seems to be some Fritzfoo on how to add things to the library. There is even an Arduino Diecimilain the mix.
Once you have your circuit all done, you can export it as an Arduino shield to Eagle.
This coolness requires a more up to date version of Eagle than is in the Ubuntu repositories, but its a breeze to install as its a simple .run file that takes care of itself. You also have to edit the Fritzing Preferences to tell it where this copy of Eagle is. And once in Eagle, you have to click a checkbox in a Preferences dialog to enable fancy functionality from Fritzing. These are all explained in detail (pictures and words) on the Fritzing site.
This is very cool for folks like me. I have ordered a few kits where I can now start to make my own Arduino shields with my laser printer and drill press and handy irons (clothing and solder).
I have been playing with it a bit and have added some functionality to it. It now supports up to 3 inputs, 6 if i add a bit of code, has a second counter since the application (applet) started, and has lines across the screen for a bit of “what the heck value is this, zen”.
Here are a few screenshots of my additions to keep you interested, we will be talking more about this at Phreaknic hopefully. Code and such will be up soon, its a bit dirty and I want to add a few more things. Maybe Morgellon will bring his scope to Phreaknic and I can see what one actually does.
After watching Citizen Engineer, I wanted to play with a slotted optical sensor, well that and a payphone, a sim card reader, a little vice and other cool electronics things. So I ordered a few from All Electronics.
As usual, I had no idea how these things work, so I started plugging in wires and using a standard analog input sketch. That did not work at all, after I heard something pop I knew I was not on the right track. Then I started looking for some help. I still have not found a datasheet, but I found a graphic that made things work for me. My exact model is the OPB3902.
There are four pins on the bottom of these things, two to work the emitter (E) (pins 1 and 3) and two for the detector (D) (pins 2 and 4). Two resistors are needed, a 330 Ohm (orange orange red) and 2.2 K (red red orange).
I mounted the Optical Sensor on a proto board, having carefully cut off the plastic bump on the bottom of the sensor. I also used a led with a 1K (brown black red) for signaling when something was activating the switch. According to the drawing 5 volts would work, so that’s what I used, along with analog pin 2 for input and digital pin 12 for the signaling led.
After running my sketch and dumping the sensor reading to serial I found that it idled at ~929 and when the sensor was activated it was ~1020. This is great, no problem to see a change of state, so I wrote a bit more code to activate the led. I did not include a delay as I wanted the led to react quickly.
Here is my code, feel free to do with it as you will!
/*
Demo for a slotted optical sensor.
I am sure that someone elses code is in here somewhere
*/
int inputPin = 2; // select the input pin for the potentiometer
int ledPin = 12; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(inputPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(inputPin); // read the value from the sensor
Serial.println(val);
if(val > 950){
digitalWrite(ledPin, HIGH); // turn the ledPin on
} else {
digitalWrite(ledPin, LOW); // turn the ledPin off
}
}
I am very excited to know how to set up this sensor. Next time I am going to find some with the hook up wires already soldered and heatshrinked on. For those that are curious, that is a Freeduino from NKC under there.