Skip to content

Instantly share code, notes, and snippets.

@yaxiek
Last active May 16, 2019 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaxiek/3cff516010479a393310082f7a5b0604 to your computer and use it in GitHub Desktop.
Save yaxiek/3cff516010479a393310082f7a5b0604 to your computer and use it in GitHub Desktop.
#include <Adafruit_NeoPixel.h>
#define NUMPIXELS 1
#define PIN 6
Adafruit_NeoPixel jellyfish = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ400);
int sensorValue1,sensorValue2,red,blue,green;
void setup(){
Serial.begin(9600);
int sensorValue1,sensorValue2,red,blue,green;
red = 0;
green = 0;
blue = 0;
jellyfish.begin();
jellyfish.setPixelColor(0, jellyfish.Color(red, green, blue));
jellyfish.show(); //光らす
}
void loop(){
//joystick -> arduino analog
sensorValue1 = analogRead(A0);
sensorValue2 = analogRead(A1);
//arduino analog -> RGB
blue = map(sensorValue1,259,761,0,255);
green = map(sensorValue2,259,761,0,255);
//Joystick output printing
Serial.print("The X and Y coordinate is:");
Serial.print(sensorValue1, DEC);
Serial.print(",");
Serial.println(sensorValue2, DEC);
Serial.println(" ");
delay(200);
jellyfish.setPixelColor(0, jellyfish.Color(red, green, blue));
jellyfish.show(); //光らす
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment