Ingredients


Eagle

Interface and Application Programming

This week I used my ATTINY45 board with a light sensor from last year's academy. I used PROCESSING to process a graphical application that changes the opacity of this circle according to the light intensity it's receiving from the sensor on the board.
This board had FTDI pin than enables the computer to read the variable values running with the sensor. I wrote a simple code on processing that first connects it to the arduinoIDE through importing the processing.serial library.

Then declaring the pin the board is reading from Then Setting up the view window parameters (size (200,200), color)
Then Drawing an ellipse linking the opacity of the ellipse to the valueRecieved from the sensor
Then finally the serialEvent after having a problem with the very high values coming from the sensor I had to remap the values by:
Removing the unwanted characters coming from the arduino string (trim)
Converting this string into a float to make it readable
Remapping this string from 900 to 1023 (observed average readings from the sensor) to 0 and 255 (the processing range of reading)
Download the Processing code

The arduino code

So far I used the AnalogReadSerial code with arduino but the erial library is not compatible with programming the ATTINY after looking for solutions online i found that by declaring both the TX and RX in this line "SoftwareSerial mySerial(1, 2); // RX, TX" after importing the serial.h library will make it work The code mainly reads the sensor value from the serial port and send it to PROCESSING under the name of sensorValue
Download the arduino code