Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Blinks Send/Receive (Test)
- *
- * --------------------------------------------------------------------------------------------------
- * IMPORTANT: To use this code in Arduino's IDE, first move the Move38-Blinks folder
- * into the right directory i.e. <user home directory>/Documents/Arduino/hardware/Move38-Blinks
- * Then open the Arduino IDE and select Tools > Board > "Move38-Blinks"
- * Now you should be good to go :) (thanks to the hard work of Josh Levine – josh.com)
- * --------------------------------------------------------------------------------------------------
- *
- * by Jonathan Bobrow
- * www.Move38.com
- * 08.29.2017
- */
- int colors[4][3] = {{255,0,0}, // Red
- {0,255,0}, // Green
- {0,0,255}, // Blue
- {255,255,0}}; // Yellow
- int isSending = 0; // 0 for receive mode, 1,2,3 for receive mode
- int neighbors[6] = {0,0,0,0,0,0};
- void setup() {
- // put your setup code here, to run once:
- // animate red circle to show reset or startup
- for(int i=0; i<FACE_COUNT; i++) {
- setAllRGB(0,0,0);
- setPixelRGB(i,200,0,0);
- delay(100);
- }
- }
- void loop() {
- // switch through 4 modes ( 0 = receive, 1,2,3 = sending 1,2,or 3 )
- if(buttonPressed()) {
- isSending = (isSending + 1) % 4;
- }
- if(isSending) {
- // get neighbor states
- for(int i=0; i<FACE_COUNT; i++) {
- // send value 1,2, or 3 on every face depending on our state
- irSendDibit(i,isSending);
- // show which value is being sent by diplaying color
- setAllRGB(colors[isSending][0],
- colors[isSending][1],
- colors[isSending][2]);
- }
- }
- else {
- // receiving
- // set all sides to dark
- setAllRGB(0,0,0);
- // get neighbor states
- for(int i=0; i<FACE_COUNT; i++) {
- // check if IR message is available
- if(irIsAvailable(i)) {
- // get value read on face
- int val = irOverFlowFlag(i);
- // save value read on face... not in use
- neighbors[i] = val;
- // set each side to the color of the received information
- setPixelRGB( i,
- colors[val][0],
- colors[val][1],
- colors[val][2]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement