Neopixel – Trying out app inventor with a bluetooth module

Yet another test with the neopixels since I’ve been bored. This one isn’t working yet but its an attempt at using an android app to program pixels on/off via a bluetooth module connected to an arduino Uno/neopixel combo. Right now I’m able to connect and send data to the arduino but its not triggering the neopixel. May need some interrupts in there, not sure yet since this is all new to me.

The basic flow of the program is Handshake with arduino via bluetooth connection >> Listen to the serial connection >> Read string >> Turn on pixel

Components
Arduino Uno
Bluetooth module(I don’t even know what I have, its basically Vcc, GND, RX, TX)
Neopixel

Programming is done using App inventor for the Android side and just a simple Arduino sketch to monitor the serial data and turn on/off the neopixel. Right now turning off a pixel is done via a long click, I may have missed if app inventor has a toggle in there. The two icons in the top left/right of the designer layout are for setting the icon to green/blue when turning them on and off(they’re both hidden, but on single click it sets the icon to one image, on long click it sets it to the other image).

App inventor designer layout

App inventor block layout. Pretty straightforward, connect to bluetooth, send via serial on click.

App inventor designer layout. Getting a nice circle shape doesn't work well(at least not without some effort)

App inventor designer layout. Getting a nice circle shape doesn’t work well(at least not without some effort)

 

 

 

 

 

 

 

 

 

 

 

 

 

Here’s some sample code for reading a string from serial and just turning the on-board LED on the Uno on/off. Taken from the Arduino website. Once I have some working code I’ll post it here.

1
2
int ledPin = 13;
String readString;

void setup() {

Serial.begin(9600);
pinMode(ledPin,OUTPUT);

}

void loop() {

while(Serial.available()){

delay(3);
char c=Serial.read();
readString+=c;
}

if (readString.length() >0){{
Serial.println(readString);
if(readString==”on”)
{
digitalWrite(ledPin,HIGH);
}
if(readString==”off”)
{
digitalWrite(ledPin,LOW);
}
readString=””;

}
}
}

You may also like...