For this week, the assignments to be accomplish are:
I choose to finally re use my Fabduino board from the Embeded week, I had a lot of problems cause my board didnt work at all!!! So, I had to re- heat the pads multiple times untill I got some results but that wasnt the only challenge but the lack of coding that I have has given me a lot of headache but Processing save the day!!!
ARDUINO
void setup() {
Serial.begin(9600); // to start the serial communication
}
void loop() {
Serial.write(map(analogRead(5), 0,1023 , 0, 255)); // the "map" function help
you to change the values of 0~1023(analog) to 0~255(RGB values) that will vhelp to increase the blue changing it to purple.
int input = analogRead (5); //pin28 on a AtMega168
Serial.println (input);v
delay(20);
}
PROCESSING
import processing.serial.*;
Serial port;
int data;
void setup(){
size(500, 500); // size of the window
port = new Serial(this, Serial.list()[3],9600); // serial communication and 3 is the port number, baud rate
}
void draw() {
if (port.available() > 0) {
data = port.read();
}
background(100, 0, data); // data is replace by the value Input from the potenciometer.
}
The analog input numbers go from 0 to 1023 and and RGB value only uses 0 to 255, therefore if you just send the raw number it wont work!! it happend to me first but after researching a litte on the issue I found a way that changes the renge numbers using the function called "map" in the Arduino ide.
For Mac Users the port that is used most of the time uses the first one (0) However, for Mac users you can use println(Serial.list()); in the Processing IDE and you can count the number of port printed in the lower list and count.
If this explanation doesnt help much here is the link that I learnt how to use the serial communication in processing.
What I was not able to do this week:
What I did but need to get better at: