| ||
#define BUTTON_PIN 2 void setup() { ... pinMode(BUTTON_PIN, INPUT); digitalWrite(BUTTON_PIN, HIGH); // connect internal pull-up ... } void loop() { ... } |
| ||
| ||
#include #include int i = 0; byte doldur[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; LiquidCrystal_I2C lcd(0x20,20,4); void setup() { lcd.init(); lcd.backlight(); lcd.createChar(0, doldur); lcd.setCursor(0, 0); } void loop() { //lcd.write(0); //lcd.print((char)0); delay(500); } |
| ||
#define S_DOWN 0x00 #define S_UP 0x01 #define S_BOX 0xff |
| |||
| ||
int pinIRLED = 12; const int laserSensor = 0; int val = 0; int maxVal = 0; int control = 0; const int redLed = 6; const int greenLed = 7; void setup() { pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(pinIRLED, OUTPUT); // set the pin as an output Serial.begin(9600); } // sets the pulse of the IR signal. void pulseON(int pulseTime) { unsigned long endPulse = micros() + pulseTime; // create the microseconds to pulse for while( micros() < endPulse) { digitalWrite(pinIRLED, HIGH); // turn IR on delayMicroseconds(13); // half the clock cycle for 38Khz (26.32×10-6s) - e.g. the 'on' part of our wave digitalWrite(pinIRLED, LOW); // turn IR off delayMicroseconds(13); // delay for the other half of the cycle to generate wave/ oscillation } } void pulseOFF(unsigned long startDelay) { unsigned long endDelay = micros() + startDelay; // create the microseconds to delay for while(micros() < endDelay); } void takePicture() { for (int i=0; i < 2; i++) { pulseON(2000); // pulse for 2000 uS (Microseconds) pulseOFF(27830); // turn pulse off for 27830 us pulseON(390); // and so on pulseOFF(1580); pulseON(410); pulseOFF(3580); pulseON(400); pulseOFF(63200); } // loop the signal twice. } void loop() { digitalWrite(greenLed, HIGH); val = analogRead(laserSensor); // read analog input pin 0 if(val > maxVal) { maxVal = val; control = maxVal - 6; } else if(val < control) { takePicture(); // take the picture Serial.println("Photo"); // prints Serial.print(val); Serial.print(" - "); Serial.print(control); Serial.println(); digitalWrite(greenLed, LOW); digitalWrite(redLed, HIGH); delay(5000); digitalWrite(greenLed, HIGH); digitalWrite(redLed, LOW); } //Serial.println(val, DEC); // prints the value read //delay(100); //takePicture(); } |
| ||
int speakerPin = 9; void setup() { pinMode(speakerPin, OUTPUT); } void loop() { sesVer(115); sesVer(120); sesVer(115); sesVer(120); delay(5000); } void sesVer(int tone) { for(int i=0; i <= 500; i++) { digitalWrite(speakerPin, HIGH); delayMicroseconds(tone); digitalWrite(speakerPin, LOW); delayMicroseconds(tone); //tone += i; } delay(50); } |
| ||
int led = 9; void setup() { pinMode(led, OUTPUT); } void loop() { randomSeed(millis()); analogWrite(led, random(0, 255)); delay(random(0, 100)); } |
| ||
Step Motor Control: http://silveiraneto.net/tag/programming/ |
| |||
| ||
C# ile Arduino için seri port kontrollü güzel bir Pwm uygulaması yazdım kodlar ve programları bilgisayarınaza indirip deneyebilirsiniz, iyi eğlenceler :) C# Application Download: http://ozhan.org/_dosyalar/icerik/C_Arduino_LedFading.zip ![]() C# with Arduino from OZHAN on Vimeo. /* bu kodlar Arduino Duemilanove için */ /* codes for Arduino Duemilanove */ int Led = 13; int PwmLed = 11; int Csharp; void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode(Led, OUTPUT); } void loop() { if (Serial.available() > 0) { Csharp = Serial.read(); Serial.println(Csharp, DEC); analogWrite(PwmLed, Csharp); } } |
| ||
Arduino ile ilk seri iletişim örneğim :) Hyper Terminal'i açın BaundRate hızını 9600 olarak ayarlayın işte size "Günaydın Dünya" klasiği :) printIn ile print farkı nedir? printIn gönderilen veri sonunda \n yani satır başına geç komutu gönderiyor. print'te ise \n yok. void setup() { Serial.begin(9600); } void loop() { Serial.println("Günaydın Dünya"); delay(500); } |