Skip to content

Instantly share code, notes, and snippets.

@bilalsavas
Created November 12, 2013 11:06
Show Gist options
  • Save bilalsavas/7429199 to your computer and use it in GitHub Desktop.
Save bilalsavas/7429199 to your computer and use it in GitHub Desktop.
Arduino potansiyometre + button örneği
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