Introduction 

We used Arduino & processing tool to develop a system in which Arduino acts with sensors where processing generates graphs. I used motion sensor for the Arduino .

 Here is the Arduino code we used for the generating the pattern.

const int numReadings = 20; // the number of readings we want to take the average of
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int lightAverage = 0; // the average of light sensor
int r = 0; //integers for RGB that we will assign with incoming data from processing
int g = 0;
int b = 0;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;

pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);

}

void loop() {
// read the input on analog pin 0:
int pot = analogRead(A0);
int light = analogRead(A1);
// print out the value you read:
Serial.print(pot);
Serial.print(“,”);
Serial.println(light);
delay(1); // delay in between reads for stability
// subtract the last reading:
total = total – readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(A1);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we’re at the end of the array…
if (readIndex >= numReadings)
// …wrap around to the beginning:
readIndex = 0;
// calculate the average:
lightAverage = total / numReadings;

/* int pot = analogRead(A0);
Serial.print(pot);
Serial.print(“,”);
Serial.println(lightAverage);
delay(10); // delay in between reads for stability

analogWrite(9, b); //the values coming from Processing are from 0-255. write them to the RGB pins
analogWrite(10, g);
analogWrite(11, r);

if (Serial.available() > 0) //if there is data coming from the Serial
{
r = Serial.parseInt(); //parse the first value of the incoming string and assign it to R
g = Serial.parseInt(); //parse the next value and assign to G
b = Serial.parseInt(); //and so on

}*/
}

Processing Code we used is :

const int numReadings = 20; // the number of readings we want to take the average of
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int lightAverage = 0; // the average of light sensor
int r = 0; //integers for RGB that we will assign with incoming data from processing
int g = 0;
int b = 0;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;

pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);

}

void loop() {
// read the input on analog pin 0:
int pot = analogRead(A0);
int light = analogRead(A1);
// print out the value you read:
Serial.print(pot);
Serial.print(“,”);
Serial.println(light);
delay(1); // delay in between reads for stability
// subtract the last reading:
total = total – readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(A1);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we’re at the end of the array…
if (readIndex >= numReadings)
// …wrap around to the beginning:
readIndex = 0;
// calculate the average:
lightAverage = total / numReadings;

/* int pot = analogRead(A0);
Serial.print(pot);
Serial.print(“,”);
Serial.println(lightAverage);
delay(10); // delay in between reads for stability

analogWrite(9, b); //the values coming from Processing are from 0-255. write them to the RGB pins
analogWrite(10, g);
analogWrite(11, r);

if (Serial.available() > 0) //if there is data coming from the Serial
{
r = Serial.parseInt(); //parse the first value of the incoming string and assign it to R
g = Serial.parseInt(); //parse the next value and assign to G
b = Serial.parseInt(); //and so on

}*/
}

Mapidrino is a project of IaaC, Institute for Advanced Architecture of Catalonia developed at Master in Advanced Architecture in 2016 by:

Students:
Sidharth Kumar & Vishnu Jadia
Faculty:

Car Menez ,Ramin Shambayati