Last active
November 23, 2016 06:57
-
-
Save JotaroS/80112d37fc3d5c3af0c9 to your computer and use it in GitHub Desktop.
Arduinoでいろいろ始めたい人が知っておいた方がいい、いろいろなこと ref: http://qiita.com/JotaroS/items/65d19e0e54a88c9d2be9
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
R = \frac{(V_{cc}-V_f)}{I_f} |
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
R = \frac{(V_{cc}-V_f)}{I_f\frac{l_0}{l}} |
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
import controlP5.*; | |
import processing.serial.*; | |
Serial myPort; | |
ControlP5 red,green,blue; | |
int Red = 100; | |
int Green = 100; | |
int Blue = 100; | |
void setup() { | |
//change the port name to yours. | |
myPort = new Serial(this,"YOUR_PORT_NAME",9600); | |
size(600,600); | |
setupSliders(); | |
} | |
void draw() { | |
myPort.write(Red); | |
myPort.write(Green); | |
myPort.write(Blue); | |
myPort.write(0); | |
background(Red,Green,Blue); | |
} | |
void setupSliders(){ | |
red = new ControlP5(this); | |
green = new ControlP5(this); | |
blue = new ControlP5(this); | |
red.addSlider("Red") | |
.setPosition(100,50) | |
.setRange(0,255) | |
.setSize(150,50); | |
green.addSlider("Green") | |
.setPosition(100,150) | |
.setRange(0,255) | |
.setSize(150,50); | |
blue.addSlider("Blue") | |
.setPosition(100,250) | |
.setRange(0,255) | |
.setSize(150,50); | |
} |
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
import controlP5.*; | |
import processing.serial.*; | |
Serial myPort; | |
ControlP5 red,green,blue; | |
int Red = 100; | |
int Green = 100; | |
int Blue = 100; | |
void setup() { | |
//change the port name to yours. | |
myPort = new Serial(this,"YOUR_PORT_NAME",9600); | |
size(600,600); | |
setupSliders(); | |
} | |
void draw() { | |
myPort.write(Red); | |
myPort.write(Green); | |
myPort.write(Blue); | |
myPort.write(0); | |
background(Red,Green,Blue); | |
} | |
void setupSliders(){ | |
red = new ControlP5(this); | |
green = new ControlP5(this); | |
blue = new ControlP5(this); | |
red.addSlider("Red") | |
.setPosition(100,50) | |
.setRange(0,255) | |
.setSize(150,50); | |
green.addSlider("Green") | |
.setPosition(100,150) | |
.setRange(0,255) | |
.setSize(150,50); | |
blue.addSlider("Blue") | |
.setPosition(100,250) | |
.setRange(0,255) | |
.setSize(150,50); | |
} |
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
//Pin assignment. | |
int red = 9; | |
int green = 10; | |
int blue = 11; | |
//PWM brightness 0 to 255 | |
int Red = 0; | |
int Blue = 0; | |
int Green = 0; | |
// the setup routine runs once when you press reset. | |
void setup() { | |
// declare pin 9 to be an output: | |
pinMode(red, OUTPUT); | |
pinMode(green, OUTPUT); | |
pinMode(blue, OUTPUT); | |
Serial.begin(9600); | |
} | |
// the loop routine runs over and over again forever. | |
void loop() { | |
//if bunch of data sent from Processing is stacked for over 3... | |
if(Serial.available()>3){ | |
Red = Serial.read(); | |
Green = Serial.read(); | |
Blue = Serial.read(); | |
Serial.read(); //the last data is dummy | |
} | |
//write data | |
analogWrite(green, Green); | |
analogWrite(red, Red); | |
analogWrite(blue,Blue); | |
} |
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
//Pin assignment. | |
int red = 9; | |
int green = 10; | |
int blue = 11; | |
//PWM brightness 0 to 255 | |
int Red = 0; | |
int Blue = 0; | |
int Green = 0; | |
// the setup routine runs once when you press reset. | |
void setup() { | |
// declare pin 9 to be an output: | |
pinMode(red, OUTPUT); | |
pinMode(green, OUTPUT); | |
pinMode(blue, OUTPUT); | |
Serial.begin(9600); | |
} | |
// the loop routine runs over and over again forever. | |
void loop() { | |
//if bunch of data sent from Processing is stacked for over 3... | |
if(Serial.available()>3){ | |
Red = Serial.read(); | |
Green = Serial.read(); | |
Blue = Serial.read(); | |
Serial.read(); //the last data is dummy | |
} | |
//write data | |
analogWrite(green, Green); | |
analogWrite(red, Red); | |
analogWrite(blue,Blue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment