Last active
May 16, 2019 13:43
-
-
Save yaxiek/3cff516010479a393310082f7a5b0604 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 <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