Created
November 15, 2019 15:16
-
-
Save thapakorn613/3f4a818fae69977438028b6566a540e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Pixy2.h> | |
// This is the main Pixy object | |
Pixy2 pixy; | |
String color; | |
void setup() | |
{ | |
Serial.begin(115200); | |
Serial.print("Starting...\n"); | |
pixy.init(); | |
} | |
void loop() | |
{ | |
int i; | |
pixy.ccc.getBlocks(); | |
// If there are detect blocks, print them! | |
if (pixy.ccc.numBlocks) | |
{ | |
Serial.print("Detected "); | |
for (i=0; i<pixy.ccc.numBlocks; i++){ | |
Serial.print(" color "); | |
if(pixy.ccc.blocks[i].m_signature == 1){ | |
color = "red"; | |
}else if(pixy.ccc.blocks[i].m_signature == 2){ | |
color = "green"; | |
} | |
else if(pixy.ccc.blocks[i].m_signature == 3){ | |
color = "art"; | |
} | |
else if(pixy.ccc.blocks[i].m_signature == 4){ | |
color = "orange"; | |
} else if(pixy.ccc.blocks[i].m_signature == 5){ | |
color = "Yellow"; | |
}else if(pixy.ccc.blocks[i].m_signature == 6){ | |
color = "Green d"; | |
} | |
else{ | |
color = "Ronin"; | |
} | |
Serial.print(color); | |
Serial.println(); | |
} | |
} | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment