Digistump Forums
The Oak by Digistump => Oak Projects => Topic started by: driffster on March 22, 2016, 09:45:23 pm
-
I been playing with the oak robot kit.
Now receiving commands from a web form :)
I use more or less the robot example code and added a few particle functions to send pseudo serial commands :
int SpeedValue = 1023;
void setup() {
botInit();
Particle.function("Movement",Movement);
Particle.publish("Oak Report", "Start");
}
int Movement(String command)
{
char buf[10];
command.toCharArray(buf, 10) ;
int firstChar = (int) buf[0];
switch (firstChar)
{
case 'f': //forward
botForward( SpeedValue);
return 1;
break;
case 'r': //reverse
botReverse( SpeedValue);
return 2;
break;
case 'd': //droite
botRight( SpeedValue);
return 3;
break;
case 'g': //gauche
botLeft( SpeedValue);
return 4;
break;
case 'D'://DROITE
botHardRight( SpeedValue);
return 5;
break;
case 'G': //GAUCHE
botHardLeft( SpeedValue);
return 6;
break;
case 's':
botStop();
return 7;
break;
}
return -1;
}
Also found a nice form on the particle docs to send POST commands directly in my browser:
<!-- Robot control -->
<!DOCTYPE>
<html>
<body>
<center>
<br>
<form action="https://api.particle.io/v1/devices/[DEVICE ID HERE]/Movement?access_token=[access token here]" method="POST">
Tell your Robot what ro do!<br>
<br>
<input type="radio" name="args" value="f">forward
<br>
<input type="radio" name="args" value="G">Hard Left
<input type="radio" name="args" value="g">Left
<input type="radio" name="args" value="d">Right
<input type="radio" name="args" value="D">Hard Right
<br>
<input type="radio" name="args" value="r">reverse
<br>
<br>
<input type="radio" name="args" value="s">Stop motor
<br>
<input type="submit" value="Do it!">
</form>
</center>
</body>
</html>
I have 0 experience in HTML, right now to make a bit efficient I'll get rid of the buttons and just put buttons, but I was wondering how I can make my browser not go to the particle report page (output of the function) ?
I plan to have some proximity sensor at some point and some encoders (well they are there but for now the data they output is not been used (got some serious bouncing going on).
-
This reply is not related to a robot project, but i wanted to thank you for posting your codes! Your //comments allowed me to modify your code into something that let's me make an web-controlled RGB LED.
thanks!
-
Hi,
I am going to build on this. I am an avid web developer and think I could help a bit in this area. However I am very new to oak and iot so I might be posting on here for some direction :)
"Also found a nice form on the particle docs to send POST commands directly in my browser"
Do you have the link that explained how to do the post via the form?
-
Here is the link from the particle docs that point directly to the html code:
https://docs.particle.io/guide/getting-started/examples/core/#use
Aside from remote control, which is not great because of the 1 sec limit on input commands, I would love just to activate different behaviors in a more autonomous robot.. I will need to complement it with different sensors first.