// Example output digital port
import processing.gainer.*;
Gainer gainer;
void setup(){
gainer = new Gainer(this);
}
void draw(){
background(0);
if(mousePressed){
if(mouseButton==LEFT)
gainer.digitalOutput(0x00);
if(mouseButton==RIGHT)
gainer.digitalOutput(0xff);
mousePressed = false;
}
}
void keyPressed()
{
if(key == '1'){
gainer.setHigh(1);
}
if(key == 'q'){
gainer.setLow(1);
}
if(key == '2'){
//this is slow.
gainer.setHigh(0);
gainer.setHigh(1);
gainer.setHigh(2);
gainer.setHigh(3);
}
if(key == 'w'){
//this is slow.
gainer.setLow(0);
gainer.setLow(1);
gainer.setLow(2);
gainer.setLow(3);
}
if(key == '3'){
//this is faster than setHigh() and setLow()
boolean b[] = {true,false,true,false};
gainer.digitalOutput(b);
}
if(key == 'e'){
//this is faster than setHigh() and setLow()
boolean b[] = {false,true,false,true};
gainer.digitalOutput(b);
}
if(key == '4'){
//this is faster than setHigh() and setLow()
int p[] = {0,1,3};
gainer.setHigh(p);
}
if(key == 'r'){
//this is faster than high() and low()
int p[] = {0,1,3};
gainer.setLow(p);
}
}
|