Team 20
For classic Sonic, we have devised a controller styled after Sonic's glove that uses color sensors to generate inputs for the game. Utilising two gloves, each with a Circuit Playground in its palm, the player will reach for colored objects designed after the Chaos Emeralds in Sonic to play the game. Each colored object will be mapped to one of the 4 controlls within Sonic. Having two gloves allows players to generate multiple inputs at a time as needed for the game's movement. Additionally, within the thumb and forefinger will be two pieces that, once brought together, will perform the input for jumping. The gloves are specifically modeled after the gloves Sonic wears, and the “Chaos Emeralds” are key items from within Sonic's world that he is often depicted or shown holding.
Our semi code, semi sudo code is split into 2. The first is for the glove jumping, the second is for color sensing.
#include <Adafruit_Circuit_Playground.h>
#include <Adafruit_CircuitPlayground.h>
int metalPin = A1;
void setup() {
CircuitPlayground.begin();
pinMode(metalPin, INPUT_PULLUP);
}
void loop() {
if (digitalRead(metalPin) == LOW) {
CircuitPlayground.setPixelColor(0, 255, 0, 0); // turn pixel red
} else {
CircuitPlayground.clearPixels();
}
}
-------------------------------------------
#include <Adafruit_Circuit_Playground.h>
#include <Adafruit_CircuitPlayground.h>
int redValue;
int greenValue;
int blueValue;
void setup() {
Serial.begin(9600);
CircuitPlayground.begin();
}
void loop() {
// RED measurement
for(int i=0;i<10;i++){
CircuitPlayground.setPixelColor(i,255,0,0);
}
delay(50);
redValue = CircuitPlayground.lightSensor();
// GREEN measurement
for(int i=0;i<10;i++){
CircuitPlayground.setPixelColor(i,0,255,0);
}
delay(50);
greenValue = CircuitPlayground.lightSensor();
// BLUE measurement
for(int i=0;i<10;i++){
CircuitPlayground.setPixelColor(i,0,0,255);
}
delay(50);
blueValue = CircuitPlayground.lightSensor();
CircuitPlayground.clearPixels();
Serial.print("R: ");
Serial.print(redValue);
Serial.print(" G: ");
Serial.print(greenValue);
Serial.print(" B: ");
Serial.println(blueValue);
// COLOR DETECTION
if (redValue > greenValue && redValue > blueValue) {
Serial.println("RED detected");
}
if (greenValue > redValue && greenValue > blueValue) {
Serial.println("GREEN detected");
}
if (blueValue > redValue && blueValue > greenValue) {
Serial.println("BLUE detected");
}
if (redValue > greenValue && blueValue > greenValue) {
Serial.println("PURPLE detected");
}
delay(300);
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.