Professional Documents
Culture Documents
With a photo resistor you can control something from your Arduino board depending on light
intake. The following circuit shows how to connect your photo resistor to the Arduino board and
read the values.
1. int ledPin = 3;
2. int photocellInput = 0;
3.
4. void setup() {
5. pinMode(ledPin, OUTPUT);
6. }
7.
8.
9. void loop() {
10.
11. photocellInput = (analogRead(0)/4); // Divides input
0-1023 to resemble to 0-255
12.
13. analogWrite(ledPin, photocellInput);
14. // The delay can be change to get the desired
dimming effect
15. delay(20);
16. }
How to hook up a Flexi Force sensor with Arduino and read out the values.
1. int fsrReading;
2.
3. void setup(void) {
4. Serial.begin(9600);
5. }
6.
7. void loop(void) {
8. fsrReading = analogRead(A0);
9. Serial.print("Analog reading = ");
10. Serial.println(fsrReading);
11.
12. delay(100);
13. }
This hack allows you to display messages to a standard Amplus LED Message Display from Clas
Ohlsson. The display is controlled by a remote control and via a RJ14 cable plugged into the
screen. Serial data is transmitted from cable to the screen. The LED Message display expects the
message you pass to it to be encrypted with a check sum. With the help of Rasmus blog post I
could generate this checksum in Arduino. I turned his Perl code into Arduino code that you can
see below.
Posted in Uncategorized | Tagged Arduino Ehternet Shield, ehternet shield, led message display,
RJ14 cable | 8 Replies
The servo motor can be controlled by using the servo library(Servo.h) in Arduino IDE. Plug in the
control wire of the servo motor into one of the PWM pins. Attach the servo object to that pin.
1. Servo servoMotor;
2. servoMotor.attach(9);
To rotate the servo motor pass in a number between 0 and 180. The servo motor can only move
up to 180 degrees.
1. myservo.write(90);
2. delay(2000);
3. myservo.write(180);
4. delay(2000);
Control Omron G5LE-1 relay that requires 12V to switch the relay on and off. The relay it self is
turning a 220VAC circuit on and off.
Posted in Uncategorized | Tagged diod, Omron G5LE-1, relay, TIP120, VAC | 2 Replies
You can easly control the current running through your LED by adding a potentiometer as part of
your circuit.
To control the LED with Arduino programming you attach the potentiometer to your analog in and
let your Arduino program decide how much to dim the LED depending on the input you get from
the potentiometer.
The input from analogRead returns a value between 0 and 1023. The analogWrite takes values
between 0 and 255. The code below show you have to convert your analog in value to make your
LED shine as bright as possible when the potentiometer is fully on.
1. int ledPin = 3;
2. int potentiomenterInput = 0;
3.
4. void setup() {
5. pinMode(ledPin, OUTPUT);
6. }
7.
8.
9. void loop() {
10.
11. potentiomenterInput = (analogRead(0)/4); // Divides
input 0-1023 to resemble to 0-255
12.
13. analogWrite(ledPin, potentiomenterInput);
14. // The delay can be change to get the desired
dimming effect
15. delay(20);
16. }