Skip to content

Instantly share code, notes, and snippets.

@AlexanderBrevig
Created February 22, 2014 13:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderBrevig/9154771 to your computer and use it in GitHub Desktop.
Save AlexanderBrevig/9154771 to your computer and use it in GitHub Desktop.
Wiring vNEXT
/*
BEAT BLINKER
Simple demo of how to use two processing units
to implement a 'used to be' hard problem
*/
Microphone mic = Microphone(2, 8000); //pin 2 samplerate 8000 ?
Filter lowPass = LowPassFilter(100);
Threshold threshold = Threshold(50); //50%
LED beatBlinker = LED(WLED);
void setup() {
mic
.to(lowPass)
.to(threshold)
.to(beatBlinker);
// naming alternatives
// mic.via
// mic.into
// mic.feed
// I also think the virtual wiring call for registering should make sure both
// objects are registered to the OL/E
}
void loop() {}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
LINE FOLLOWER
Line following robot, property control version
*/
AnalogSensor lineSensor = ColorSensor(2);
Threshold threshold = Threshold(20); //let's say anything below 20% is black
If isThresholdMet = If();
Motor leftMotor = DCMotor(5,6);
Motor rightMotor = DCMotor(7,8);
void setup() {
lineSensor
.to(threshold)
.to(isThresholdMet)
.to(leftMotor.speed, rightMotor.speed);
// in this version, endoints can expose properties that is recognized as Virtual Wiring controllable
// when registered as wirtual wiring controllable, the value will default each tick as opposed to be stateful
// also, this demonstrates the possibility of using varargs to send from multiple outputs
// the isThresholdMet will send to the first out while true, and the second while false
}
void loop() {}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment