Saturday, May 23, 2009

my "sun jar"

Tried to make my own "sun jar" around a year ago. Left it on breadboard until today...



Find the schematic below. Added a switch to keep the LED off all the time... which effectively makes the whole thing a solar powered battery charger...



Notes to self:

  1. The solar panel is directly connected to the battery for charging. Without any control on voltage or current. May damage the battery in a long run. But then, the solar panel used is not that powerful... so....
  2. A normal LED requires more than 1 AA cell to power it up. To overcome this, the center-tapped-coil and one of the transistor formed a switching circuit. It generates voltage high enough to light up the LED with less than one volt.
  3. Unlike the commercially available Sun Jar, this circuit doesn't use photoresistor to control when to light up the LED. Instead, a transistor is used to detect the voltage output of the solar panel.


Sunday, May 17, 2009

Arduino test: voltmeter

First experiment with Arduino. Trying to implement a voltmeter.

Each analog input of Arduino has 1024 steps. From 0 to 5 volt. This experiment used a simple voltage divider to measure roughly 0 to 12 volt (using 50k as R1 and 4k3 as R2).

By varying the values of R1 and R2, the precision and range of the measurement can be changed.





Here is the Arduino code:

// variables for input pin and control LED
  int analogInput = 1;
  int LEDpin = 13;
  int prev = LOW;
  int refresh = 1000;
  float vout = 0.0;
  float vin = 0.0;
  float R1 = 50000.0;    // !! resistance of R1 !!
  float R2 = 4300.0;     // !! resistance of R2 !!

// variable to store the value
  int value = 0;


void setup(){

  // declaration of pin modes
  pinMode(analogInput, INPUT);
  pinMode(LEDpin, OUTPUT);

  // begin sending over serial port
  Serial.begin(9600);
}

void loop(){
  // read the value on analog input
  value = analogRead(analogInput);
  //Serial.print("value=");
  //Serial.println(value);

  if (value >= 1023) {
    Serial.println("MAX!!");
    delay(refresh);
    return;
  }
  else if (value <= 0) {
    Serial.println("MIN!!");
    delay(refresh);
    return;
  }

  // blink the LED
  if (prev == LOW) {
    prev = HIGH;
  } else {
    prev = LOW;
  }
  digitalWrite(LEDpin, prev);

  // print result over the serial port
  vout = (value * 5.0) / 1024.0;
  vin = vout / (R2/(R1+R2));

  //Serial.print("vout=");
  //Serial.println(vout);

  Serial.print(vin);
  Serial.println(" volt");

  // sleep...
  delay(refresh);
}

Saturday, May 16, 2009

Arduino & LCD Smartie

Here is a test of Arduino with LCD Smartie. You can get the Arduino sketch here.


Tuesday, May 12, 2009

開箱文…

早兩日係淘寶 order 的新玩具…



Arduino 主板 + LCD and input shields


先試主板…


合體!


試 LCD panel