anu po pwede kong gawin dito?;
Project:
controlling 2 servos using 2 potentiometers via bluetooth connection in arduino...
ung isa pong arduino nakaconnect sa 2 servo and ung isa sa 2 potentiometers.
may alam po b kau na way kung paano mahihiwalay ung bytes na sinesend ng dalawang potentiometer?
Nagawa ko na po kc ung isang pair ng servo and potentiometer.. di ko na po alam kung paano ako magdadagdag ng isa pang pair....
E2 po sample code ko.. pair ng servo and potentiometer:
Sender (arduino with pot):
int potPin = 0;
int buttonpin = 10;
int buttonState = 0;
void setup()
{
pinMode(buttonpin, INPUT);
Serial.begin(115200);
}
void loop()
{
int potVal = analogRead(potPin);
byte servoVal = map(potVal, 0, 1023, 0, 180);
Serial.write(servoVal);
delay(10);
buttonState = digitalRead(buttonpin);
if( buttonState == HIGH){
Serial.print( 'w');
}
}
Receiver(arduino with servo):
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
if(Serial.available() > 0)
{
byte servoAng = Serial.read();
// Send the servo to the position read... <-- you get to make this happen
myservo.write(servoAng);
}
}
As for now, last na po ito )))
please help me po