Skip to content

Commit

Permalink
Add example as a file
Browse files Browse the repository at this point in the history
  • Loading branch information
HoldYourWaffle committed Aug 15, 2018
1 parent be55b39 commit 6f0a988
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions BlinktExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import jimbo.pijava.blinkt.BlinktController;
import java.awt.Color;

public class BlinktExample {

public static void main(String[] args) throws InterruptedException {
System.out.println("Starting demo"); //the VM can take some time to load on the pi so we print a nice little heads up that we're starting

BlinktController blinkt = new BlinktController(); //create the controller
blinkt.setBrightness(.1F); //we don't want to blind ourselves

boolean movingForward = true;
int i = 1;

while (true) {
blinkt.clear(); //clear any previous state

blinkt.set(i-1, Color.RED); //set the left pixel to red
blinkt.set(i, 0, 255, 0); //set the middle pixel to green
blinkt.set(i+1, Color.BLUE, 1); //set the last pixel to blue with full brightness

blinkt.push(); //push state to the GPIO pins

//Some back and forth controlling
if (movingForward) i++;
else i--;

if (i >= 7) {
i = 5;
movingForward = false;
} else if (i <= 0) {
i = 2;
movingForward = true;
}

Thread.sleep(250);
}
}

}

0 comments on commit 6f0a988

Please sign in to comment.