[heading size=”1″ color=”#80D6F9″]The Code[/heading]
Let’s see what goes on inside the code. You can read about Circuit Touch (3), Key Press (19) and LED (5) on your Handout.
[toggle active=”no” title=”Here is the Code”]
// include the Quirkbot library to your program:
#include “Quirkbot.h”
// create your Quirkbot nodes here:
CircuitTouch circuitTouch1;
CircuitTouch circuitTouch2;
CircuitTouch circuitTouch3;
CircuitTouch circuitTouch4;
KeyPress keyPress1;
KeyPress keyPress2;
KeyPress keyPress3;
KeyPress keyPress4;
Led led1;
Led led2;
Led led3;
Led led4;
// create your other Arduino variables and functions here:
void setup(){
// setup your Quirkbot nodes here:
circuitTouch1.place = H;
circuitTouch1.sensitivity = 0.63;
circuitTouch1.min = 0;
circuitTouch1.max = 1;
circuitTouch2.place = LA;
circuitTouch2.sensitivity = 0.49;
circuitTouch2.min = 0;
circuitTouch2.max = 1;
circuitTouch3.place = RA;
circuitTouch3.sensitivity = 0.6;
circuitTouch3.min = 0;
circuitTouch3.max = 1;
circuitTouch4.place = LL;
circuitTouch4.sensitivity = 0.75;
circuitTouch4.min = 0;
circuitTouch4.max = 1;
keyPress1.trigger.connect(circuitTouch1.out);
keyPress1.key = KEY_UP;
keyPress2.trigger.connect(circuitTouch2.out);
keyPress2.key = KEY_RIGHT;
keyPress3.trigger.connect(circuitTouch3.out);
keyPress3.key = KEY_LEFT;
keyPress4.trigger.connect(circuitTouch4.out);
keyPress4.key = KEY_S;
led1.light.connect(circuitTouch1.out);
led1.place = H;
led2.light.connect(circuitTouch2.out);
led2.place = LE;
led3.light.connect(circuitTouch3.out);
led3.place = RE;
led4.light.connect(circuitTouch4.out);
led4.place = LL;
// put your other Arduino setup code here, to run once:
}
void loop(){
// put your main Arduino code here, to run repeatedly:
}
[/toggle]
[toggle active=”no” title=”What does it do?”]
The Circuit Touch activates when you touch the corresponding part of the Quirkbot. As soon as it detects your finger, it sends two signals. One to the LED (a light which turns on) and one to the Keystroke – in this case the three arrows and the space bar.
[/toggle]
[button style=”medium” type=”rounded” color=”#COLOR_CODE” background=”#COLOR_CODE” src=”http://www.conductivemusic.uk/shine1b” target=”_blank”]NEXT[/button]