Introduction: Arduino Zonnescherm

Als instructable ga ik een zonnescherm bouwen die zichzelf in en uit doet. Dit doet die op basis van een sensor die het licht meet en een motortje die aangestuurd wordt wanneer het nodig is.

Step 1: Materialen

Zorg voor de volgende onderdelen:
Laptop
Arduino
Resistor (10k)
Breadboard leads

LDR (sensor)
Servo (motor)

Step 2: Sluit De Componenten Aan

Volg het volgende schema om de LDR werkend te krijgen.

Voor de Servo moet je een verbinding maken met de 5V pin. Verder heb je een verbinding nodig met GND en een pinnetje die in pin '10' zit op de Arduino.

Doe de pinnetjes in je servo zoals aangegeven is op afbeelding hierboven. Let goed op de draadjes!

Step 3: Upload De Code Op Je Arduino

De volgende code zal direct werken wanneer je de bouw precies hetzelfde hebt gedaan als hierboven is aangegeven.

****//////BEGIN VAN DE CODE*****////////////
/*

Analog input, analog output, serial output

Reads an analog input pin, maps the result to a range from 0 to 255 and uses the result to set the pulsewidth modulation (PWM) of an output pin. Also prints the results to the serial monitor.

The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 9 to ground

created 29 Dec. 2008 modified 9 Apr 2012 by Tom Igoe

This example code is in the public domain.

*/

#include

Servo myservo;

// These constants won't change. They're used to give names // to the pins used: const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out)

int pos = 0; bool sun = false; bool screen = false;

void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); }

void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue);

if(sensorValue <= 850){ //sun is shining, TURN IT ON if(pos == 0){ myservo.attach(10); } sun = true; } if(sensorValue >= 980){ //clouds incominggg if(pos > 760){ myservo.attach(10); } sun = false; }

if(sun == true && screen == false){ pos++; // ++ the position myservo.write(pos); Serial.print(pos); if(pos >760){ screen = true; myservo.detach(); } } if(sun == false && screen == true){ pos--; myservo.write(pos); if(pos == 0){ screen = false; myservo.detach(); } }

// wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(2);

}

****//////EINDE VAN DE CODE*****////////////

Step 4: Stylize

Gebruik nu 3d modellen om uit te printen.

In mijn geval zal ik dit printen:
http://www.thingiverse.com/thing:811/#files

Je kunt natuurlijk zelf nog verder knutselen maar ik ben meer van het coden dan van het knutselen.

Step 5: Eindresultaat

Je hebt nu een kleine nabootsing van een automatisch zonnescherm, wanneer de sensor merkt dat er zonnestralen / lichtflitsen op de sensor komen zal de motor naar links draaien. Wanneer die merkt dat het donker wordt gaat die automatisch de andere kant op.