Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino baslangic dersleri 10
#define yesilPin 3
#define kirmiziPin 5
#define maviPin 6
void setup()
{
Serial.begin(9600);
pinMode(kirmiziPin, OUTPUT);
pinMode(yesilPin, OUTPUT);
pinMode(maviPin, OUTPUT);
Serial.println("Renk secimi icin Kirmizi: k, Mavi: m, Yesil: y, Beyaz: b, Sari: s, Turkuaz: t 'dir.");
}
void loop()
{
char veri = 0;
if (Serial.available() > 0)
{
veri = Serial.read();
if (veri == 'k')
{
analogWrite(kirmiziPin, 255);
analogWrite(yesilPin, 0);
analogWrite(maviPin, 0);
Serial.println("Kirmizi");
}
else if (veri == 'y')
{
analogWrite(kirmiziPin, 0);
analogWrite(yesilPin, 255);
analogWrite(maviPin, 0);
Serial.println("Yesil");
}
else if (veri == 'm')
{
analogWrite(kirmiziPin, 0);
analogWrite(yesilPin, 0);
analogWrite(maviPin, 255);
Serial.println("Mavi");
}
else if (veri == 'b')
{
analogWrite(kirmiziPin, 255);
analogWrite(yesilPin, 255);
analogWrite(maviPin, 255);
Serial.println("Beyaz");
}
else if (veri == 's')
{
analogWrite(kirmiziPin, 255);
analogWrite(yesilPin, 255);
analogWrite(maviPin, 0);
Serial.println("Sari");
}
else if (veri == 't')
{
analogWrite(kirmiziPin, 0);
analogWrite(yesilPin, 255);
analogWrite(maviPin, 255);
Serial.println("Turkuaz");
}
else if (veri != 0)
{
analogWrite(kirmiziPin, 0);
analogWrite(yesilPin, 0);
analogWrite(maviPin, 0);
Serial.println("Renk Tanımlı Degil!!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.