Hi I need help. I'm a beginner with Arduino nano. Trying to make a simple project for a couple months and am a bit lost in it. I have a nano connected to Bluetooth (tx to Rx, Rx to tx pins) and a 4wire stepper motor. I can control it without the Bluetooth but can't seem to figure out the code with Bluetooth. I want to be able to control it through 2 buttons on an android app made in MIT app inventor. If I press one button, it makes the motor turn half a turn 180 degrees, if I press the other button it makes the motor do a full 360 degree turn and stops(degrees don't matter as I can adjust those with steps). I have the app, it connects to Bluetooth on nano but can't figure out the code on the Arduino side. Ive coded the app so when I press button 1, it sends '1', if I press the other it sends '2' through bluetooth. My code is a combination of other people's code but doesn't work. Here's the code I have so far that doesn't work.
All help greatly appreciated!
Updated code
#include <Stepper.h>
#include<SoftwareSerial.h>
const int stepsPerRevolution1 = 200;
const int stepsPerRevolution2 = 400;
char Incoming_value = 0;
boolean didMyOneTimeAction = false;
Stepper myStepper1(stepsPerRevolution1, 3,10,8,11);
Stepper myStepper2(stepsPerRevolution2, 3,10,8,11);
void setup() {
Serial.begin(38400);
myStepper1.setSpeed(80);
myStepper2.setSpeed(80);
}
void loop() {
if (didMyOneTimeAction == false)
{
if(Serial.available() > 0 ) {
Incoming_value = Serial.read();
Serial.print (Incoming_value);
Serial.print ("\n");
if(Incoming_value == 1);
myStepper1.step(stepsPerRevolution1);
}
else if(Incoming_value == 2);
myStepper2.step(stepsPerRevolution2);
didMyOneTimeAction = true;
} }