Testing DFRobot APC220 Radio Communication Module with Arduino Blink Example

I got my hands on the APC 220 Communication Module from DFRobot for our robotic fish project [1] .

In this test, I use the LED Blink example, modded to include the serial port reading. While in the LED Blink example, you can just hook the positive point of LED to Pin 13 and its negative point to ground (GND), while the additional connections for the APC 220 module are as below:

APC220 Arduino connection

As shown in the figure, the connections are simple since I just wanted to perform a simple test to see whether the module is working fine:

APC 220 Arduino Blink

Below are the codes. You are free to change the serial baud number, I used 57600. Once the codes were uploaded to your Arduino board,

  1. connect everything,
  2. pop in the Serial Monitor on your Arduino IDE console,
  3. choose the respective baud (mine is 57600),
  4. send capital H to the console, observe the LED is turned on,
  5. send other character e.g. i to the console, observe the LED is turned off.

Happy coding!

// Modified from Arduino Playground tutorial: http://www.arduino.cc/playground/Learning/Tutorial01
char val; // variable to receive data from the serial port
int ledpin = 13; // LED connected to pin 13 (on-board LED)

void setup() {
  pinMode(ledpin, OUTPUT);  // pin 13 (built-in LED) as OUTPUT
  Serial.begin(57600);       // start serial communication at 57600bps 
}
void loop() {
  if( Serial.available() )       // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
  }
  if( val == 'H' )               // if 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else { 
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  }
  delay(100);                    // wait 100ms for next reading
}

[1] I have established a research group named Marine Robotics Research Group. Someday I’ll make some write up for it.

Advertisements