Analog PIN live plot

Read analog pins AN0 to AN5 and plot signals in real time

Analog PIN live plot

Plot signals from analog pins in real time using RoboRemo app.

Materials needed:
- Arduino UNO (or similar) + USB cable for it
- DC adapter for Arduino
- BlueSMiRF module (or similar, please check the BaudRate)
- QTR-8RC Reflectance Sensor Array (or any analog signal source from 0 to 5V)
- wires
- Android phone with RoboRemo app installed

Introduction

Plotting analog signals is very useful in different areas. You can debug an analog sensor by visualizing the signal variations with the measured value. You can build a simple EKG or EEG device and lots of other cool stuff.
In this example we use the QTR-8RC Reflectance Sensor Array which is used in Line Follower Robots. We plot the signals from the 8 sensors to see how responsive they are and what is the range of the signal variation. The first thing to consider when building a line follower is to make sure the line sensor is working and properly read.

Steps:

1.
Upload the code to your Arduino:

// Multi-channel Analog data acquisition via Bluetooth
// using RoboRemo app
// www.roboremo.com

// Hardware setup:
// BT module   Arduino
// GND ------- GND
// VCC ------- 5V
// TX-O ------ pin0
// RX-I ------ pin1

// input0 ----- A0
// input1 ----- A1
// input2 ----- A2
// input3 ----- A3
// input4 ----- A4
// input5 ----- A5

#define bluetooth Serial

int on = 0; // OFF

char cmd[100];
int cmdIndex;

boolean cmdStartsWith(char *st) {
  for(int i=0; ; i++) {
    if(st[i]==0) return true;
    if(cmd[i]==0) return false;
    if(cmd[i]!=st[i]) return false;;
  }
  return false;
}

void exeCmd() {
  if( cmdStartsWith("on") ) on = 1;
  if( cmdStartsWith("off") ) on = 0;
}

void setup() {
  
  delay(500); // wait for bluetooth module to start

  bluetooth.begin(115200); // Bluetooth default baud is 115200
  
  cmdIndex = 0;
}

void loop() {
  
  while(bluetooth.available()) {
    
    char c = (char)bluetooth.read();
    
    if(c=='\n') {
      cmd[cmdIndex] = 0;
      exeCmd();  // execute the command
      cmdIndex = 0; // reset the cmdIndex
    } else {      
      cmd[cmdIndex] = c;
      if(cmdIndex<99) cmdIndex++;
    }
  }
  
  if(on) {
    bluetooth.print( (String)"A0 " + analogRead(A0) + "\n" );
    bluetooth.print( (String)"A1 " + analogRead(A1) + "\n" );
    bluetooth.print( (String)"A2 " + analogRead(A2) + "\n" );
    bluetooth.print( (String)"A3 " + analogRead(A3) + "\n" );
    bluetooth.print( (String)"A4 " + analogRead(A4) + "\n" );
    bluetooth.print( (String)"A5 " + analogRead(A5) + "\n" );
    delay(20);
  }
}


In this example we use Hardware Serial.
But Arduino UNO also uses Hardware Serial for programming, so when you program the Arduino, you need to disconnect the Bluetooth module, and to run the circuit, you need to disconnect the USB cable and connect the Arduino DC power supply.

2.
Connect the Bluetooth module and the line sensor:

arduino-read-qtr-8rc.jpg

3.
Connect your Arduino to the DC power supply.

4.
Configure the RoboRemo interface and enjoy :)