I am using an arcuino uno, a HC-05, a button and 2 servos. The physical version of the program works great:
#include <Servo.h>
Servo MioServo;
Servo MioServo2;
int pulsante;
int stato;
int pot = 0;
int potOLD;
int pos;
int pos2;
void setup()
{
Serial.begin(9600);
pinMode(4, INPUT);
MioServo.attach(6);
MioServo2.attach(7);
pinMode(13, OUTPUT);
potOLD = pot;
}
void loop()
{
pulsante = digitalRead(4);
if (pulsante == 1)
{
stato = !stato;
Serial.println ("stato = " + String(stato));
while (pulsante == 1) pulsante = digitalRead(4);
}
if (stato == 0)
{
digitalWrite(13, LOW);
}
if (stato == 1)
{
pot = analogRead(0);
if ((pot > (potOLD + 100) || pot < (potOLD - 100))) Serial.println("Potenziometro = " + String(pot));
potOLD = pot;
digitalWrite(13, HIGH);
MioServo.write(pos);
MioServo2.write(pos2);
pos = map(pot, 0, 1023, 10, 165);
pos2 = map(pot, 0, 1023, 165, 10);
delay(15);
}
}
I wanted to “translate” this code using blynk but i can’t do it
The logic is the button works as a “handbrake” when it is 0 the servos do not follow the potentiometer, while if it is at 1 the servos follow the potentiometer.
Someone can help me?
C:\Users\falbo.l\Downloads\Arduino_StepperMotor_Potentiometer_Buttons\Arduino_StepperMotor_Potentiometer_Buttons.ino: In function 'void setup()':
Arduino_StepperMotor_Potentiometer_Buttons:26:3: error: 'SerialBLE' was not declared in this scope
SerialBLE.begin(9600);
^~~~~~~~~
C:\Users\falbo.l\Downloads\Arduino_StepperMotor_Potentiometer_Buttons\Arduino_StepperMotor_Potentiometer_Buttons.ino:26:3: note: suggested alternative: 'Serial'
SerialBLE.begin(9600);
^~~~~~~~~
Serial
Più di una libreria trovata per "Servo.h"
Usata: \\Serverone\studenti\falbo.l\Documenti\Arduino\libraries\Servo
Non usata: C:\Program Files (x86)\Arduino\libraries\Servo
Più di una libreria trovata per "BlynkSimpleSerialBLE.h"
Usata: \\Serverone\studenti\falbo.l\Documenti\Arduino\libraries\blynk-library-master
Non usata: \\Serverone\studenti\falbo.l\Documenti\Arduino\libraries\Blynk
exit status 1
'SerialBLE' was not declared in this scope