Day-1

AI on Edge using Arduino by G-EDGE toolkit from GRIET

Step-1


Open Arduino tool and create a new project

which has two functions:

  1. Setup

  2. Loop


The sample psuedo code looks like this:

void setup() {

// put your setup code here, to run once:

}

void loop() {

// put your main code here, to run repeatedly:

}


Add the code to setup and loop functions:

Setup function used for initialization parameters, ports and variables

The functionality which needs to be repeated are kept part of loop function

The example code like:


#define S2 16



#define S3 17


#define sensorOut 18


int frequency = 0;


void setup()


{


pinMode(S2, OUTPUT);


pinMode(S3, OUTPUT);


pinMode(sensorOut, INPUT);


Serial.begin(115200);


}


void loop()


{


// Setting red filtered photodiodes to be read


digitalWrite(S2,LOW);


digitalWrite(S3,LOW);


// Reading the output frequency


frequency = pulseIn(sensorOut, LOW);


// Printing the value on the serial monitor


Serial.print("R= ");//printing name


Serial.print(frequency);//printing RED color frequency


Serial.print(" ");


delay(100);


// Setting Green filtered photodiodes to be read


digitalWrite(S2,HIGH);


digitalWrite(S3,HIGH);


// Reading the output frequency


frequency = pulseIn(sensorOut, LOW);


// Printing the value on the serial monitor


Serial.print("G= ");//printing name


Serial.print(frequency);//printing RED color frequency


Serial.print(" ");


delay(100);


// Setting Blue filtered photodiodes to be read


digitalWrite(S2,LOW);


digitalWrite(S3,HIGH);


// Reading the output frequency


frequency = pulseIn(sensorOut, LOW);


// Printing the value on the serial monitor


Serial.print("B= ");//printing name


Serial.print(frequency);//printing RED color frequency


Serial.println(" ");


delay(100);


}

Select Serial Monitor for viewing output

Data Generation:

Use the various sensors like Sound, Color, Accelerometer, Temperature, Humudity and many more

Connect the sensors and write the suitable to code to capture the data and print on to serial monitor.

Copy the data from output / Serial Monitor and paste into notepad save with relevant name with ".csv" extension.