├── README.md ├── PLAN.md ├── pseudocode.txt └── arduino ├── lightsensorread └── lightsensorread.ino ├── arduino.ino └── lightSensorTest.ino /README.md: -------------------------------------------------------------------------------- 1 | # lighttrackinator 2 | Arduino tracks light 3 | Still WIP 4 | -------------------------------------------------------------------------------- /PLAN.md: -------------------------------------------------------------------------------- 1 | 1. Voeg lichtsensoren toe en zorgt dat dat ledjes kan aan laten sturen. 2 | 2. Zorg dat de lichtsensoren een de stappenmoten kunnen aansturen. 3 | 3. Zorg dat je de moter kan aansturen dmv lichtsterkte 4 | 4. 5 | -------------------------------------------------------------------------------- /pseudocode.txt: -------------------------------------------------------------------------------- 1 | 2 | herhaal oneindig 3 | scan sensor 1 4 | 5 | scan sensor 2 6 | 7 | if sensor 1 > 2 8 | // ga naar links 9 | 10 | else if sensor 2 < 1 11 | // ga naar rechts 12 | 13 | else sensor 2 == 1 14 | // blijf recht door 15 | -------------------------------------------------------------------------------- /arduino/lightsensorread/lightsensorread.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int sensor1pin = 0; 5 | int sensor2pin = 1; 6 | 7 | Servo motor; 8 | 9 | int sensor1lux = 0; 10 | int sensor2lux = 0; 11 | 12 | void setup() { 13 | 14 | Serial.begin(9600); 15 | 16 | motor.attach(9); 17 | } 18 | 19 | void loop() { 20 | 21 | sensor1lux = analogRead(sensor1pin); 22 | sensor2lux = analogRead(sensor2pin); 23 | 24 | if (sensor1lux > sensor2lux) { 25 | Serial.println("rechts"); 26 | motor.write(0); 27 | } else if (sensor2lux > sensor1lux) { 28 | Serial.println("links"); 29 | motor.write(180); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /arduino/arduino.ino: -------------------------------------------------------------------------------- 1 | int led = 9; 2 | int brightness = 0; 3 | int fadeAmount = 5; 4 | 5 | 6 | void setup() { 7 | // put your setup code here, to run once: 8 | pinMode(led, OUTPUT); 9 | } 10 | 11 | void loop() { 12 | // set the brightness of pin 9: 13 | analogWrite(led, brightness); 14 | 15 | // change the brightness for next time through the loop: 16 | brightness = brightness + fadeAmount; 17 | 18 | // reverse the direction of the fading at the ends of the fade: 19 | if (brightness == 0 || brightness == 255) { 20 | fadeAmount = -fadeAmount ; 21 | } 22 | // wait for 30 milliseconds to see the dimming effect 23 | delay(30); 24 | } 25 | -------------------------------------------------------------------------------- /arduino/lightSensorTest.ino: -------------------------------------------------------------------------------- 1 | int photocellPin = 0; // the cell and 10K pulldown are connected to a0 2 | int photocellReading; // the analog reading from the sensor divider 3 | int LEDpin = 11; // connect Red LED to pin 11 (PWM pin) 4 | int LEDbrightness; // 5 | void setup(void) { 6 | // We'll send debugging information via the Serial monitor 7 | Serial.begin(9600); 8 | } 9 | 10 | void loop(void) { 11 | photocellReading = analogRead(photocellPin); 12 | 13 | Serial.print("Analog reading = "); 14 | Serial.println(photocellReading); // the raw analog reading 15 | 16 | analogWrite(LEDpin, photocellReading > 299 ? 0 : 255); 17 | 18 | delay(100); 19 | } 20 | --------------------------------------------------------------------------------