I want to try my servo wirelessly using spark core but i did not find how to assemble the components…someone could helps me and give me the electronic diagram …
Can you give us a little more detail on what you want to do, exactly?
I want to try the servo example .
http://docs.spark.io/#/firmware/libraries-servo
http://arduino.cc/en/reference/servo
Let me know if that helps.
Basically, just hook 5V GND and signal to the Core from the Servo. You’ll need to know which wires are which on your particular servo (that link I posted should help, Google is also your friend here).
Here is a full Wireless Servo example:
// WIRELESS SERVO EXAMPLE CODE
// BDub 4/7/2014
//
// Connect RED wire to VIN (~5V)
// Connect ORANGE, YELLOW, or WHITE wire to A0 (servo signal)
// Connect BLACK or BROWN wire to GND (0V)
// Adjust these connections for your particular servo
// if you have a wiring diagram for it.
//
//
// COMPLEMENTARY API CALL
// POST /v1/devices/{DEVICE_ID}/{FUNCTION}
//
// # EXAMPLE REQUEST
// curl https://api.spark.io/v1/devices/0123456789abcdef01234567/servo \
// -d access_token=1234123412341234123412341234123412341234 \
// -d "args=180"
//----------------------------------------------------------------------------
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
// attaches the servo on the A0 pin to the servo object
myservo.attach(A0);
// register the Spark function
Spark.function("servo", updateServo);
}
void loop()
{
// do nothing
}
//this function automagically gets called upon a matching POST request
int updateServo(String command)
{
// convert string to integer
uint8_t pos = command.toInt();
// process if integer is 0 - 180
if(pos <= 180)
{
// tell servo to go to position in variable 'pos'
myservo.write(pos);
// return an integer success code that can be processed by our app
return 200;
}
else {
// return an integer error code that can be processed by our app
return -1;
}
}
@BDub thank you for your help and also for @timb
I want to know , how to power a 5v stepper using the spark core knowing that it’s powered by 3.3v ?
You can use a separate battery or power supply only connected to the SERVO or STEPPER’s power input, connect GND to GND and then your control output just goes to the servo’s control input. The stepper needs more control, and usually a buffer between the Spark and the Stepper. Something like a ULN2003 darlington array will work. If you really meant Stepper I can point you to more info. Otherwise Servo is pretty well covered here.
To address the 3.3V vs. 5V… the Servo must have TTL inputs… or something similar. TTL inputs are 0.8V = LOW and 2V = HIGH, typically. Which would explain why 3.3V output can drive a TTL input well enough that you don’t notice any problems.
Thank you @BDub for your help !