Skip to content

Instantly share code, notes, and snippets.

@murilopolese
Last active February 20, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murilopolese/cf2b13b37d24c56eee17b2f65bf1162c to your computer and use it in GitHub Desktop.
Save murilopolese/cf2b13b37d24c56eee17b2f65bf1162c to your computer and use it in GitHub Desktop.
Cleide
// include the Quirkbot library to your program:
#include "Quirkbot.h"
// create your Quirkbot nodes here:
CircuitTouch leftSensor;
CircuitTouch rightSensor;
ServoMotor servoMotor1;
VoltageOutput backward;
VoltageOutput forward;
// create your other Arduino variables and functions here:
void setup(){
// setup your Quirkbot nodes here:
leftSensor.place = LL;
leftSensor.sensitivity = 0;
leftSensor.min = 0;
leftSensor.max = 1;
rightSensor.place = H;
rightSensor.sensitivity = 0;
rightSensor.min = 0;
rightSensor.max = 1;
servoMotor1.place = BP4;
backward.in = 0;
backward.place = BP1;
forward.in = 0;
forward.place = BP2;
// put your other Arduino setup code here, to run once:
}
void loop(){
if( leftSensor.out.get() == 1 || rightSensor.out.get() == 1 ) {
float servoP = 0.5;
if( leftSensor.out.get() == 1 ) {
servoP = 0.75;
}
if( rightSensor.out.get() == 1 ) {
servoP = 0.2;
}
forward.in = 0;
backward.in = 1;
servoMotor1.position = servoP;
delay( 2000 );
servoMotor1.position = 0.5;
forward.in = 1;
backward.in = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment