Created
November 12, 2013 11:06
-
-
Save bilalsavas/7429199 to your computer and use it in GitHub Desktop.
Arduino potansiyometre + button örneği
This file contains hidden or 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 processing.serial.*; | |
import cc.arduino.*; | |
// arduino tanımlama [2] yerine çalıştırılacak olan COM un indexi | |
Arduino a = new Arduino(this, Arduino.list()[2], 57600); | |
color c; | |
void setup() | |
{ | |
size(1600,900); | |
noStroke(); | |
println(Arduino.list()); | |
a.pinMode(2, Arduino.INPUT); | |
} | |
int sensorValue=0; | |
void draw() | |
{ | |
// potansiyometre değeri sensorValue | |
sensorValue = a.analogRead(3); | |
fill(c); | |
ellipse(width/2,height/2,sensorValue,sensorValue); | |
// button basılıysa renk random | |
if(a.digitalRead(2)==Arduino.HIGH) | |
{ | |
c = color(random(255),random(255),random(255)); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment