Here is what you will need to complete the Arduino side of the project:
- PhotoCell (or PhotoResistor)
- 10K resistor
- Breadboard
- Arduino UNO
- 3-4 wires (to connect it all together)
- USB cable to upload sketch and for Serial communication with Processing.
The Fritzing sketch:
The Arduino Code:
1 |
int photoRPin = 0; |
And this will allow you to display
the value of the "adjustedLightLevel" on your computer screen, as seen
below.
Arduino
sketch explanation:
Serial.begin(9600) : starts
the serial communication between the Arduino and Processing
lightLevel=analogRead(photoRPin) : take a reading from the analog pin 0.
minLight and maxLight: automatically adjust the minimum and maximum range of the sensor
adjustedLightLevel: used to map the reading from the PhotoCell to a value between 0-100.
The adjustment of the light level is not necessary, and could be handled in Processing instead.
The delay(50) at the end of the sketch, is only used to slow down the transmission of the Serial messages to Processing. Depending on what you want to do with the sensor data, you may wish to increase or decrease the amount of delay.
lightLevel=analogRead(photoRPin) : take a reading from the analog pin 0.
minLight and maxLight: automatically adjust the minimum and maximum range of the sensor
adjustedLightLevel: used to map the reading from the PhotoCell to a value between 0-100.
The adjustment of the light level is not necessary, and could be handled in Processing instead.
The delay(50) at the end of the sketch, is only used to slow down the transmission of the Serial messages to Processing. Depending on what you want to do with the sensor data, you may wish to increase or decrease the amount of delay.


I want to to connect simulink model of AUV to arduino ,sensors and actuators and want technical details of it
ReplyDeleteHi Anonymous,
DeleteSounds like an interesting project, but have never used Simulink, and have never heard of it until I saw your comment. Perhaps try the Arduino Forums and draw from collective intelligence. Sorry I could not help.