butona basınca role 1 sn çekip bırakmasını ve bir daha butona basınca sistemin durmasını istiyorum Youtube da araştırdım bulamadım.
Sadece butonla çalıştırma ve kapatma sistemi var.
/* * This is the Arduino code for push button to push Fade ON and Push Fade OFF a and LED * * Original code was to turn ON and OFF AC bulbe. watch video instruction on video * Be carefull working with AC is dangrous. Disconnect from AC power when working and wear protective gloves when touch the AC components. Update Oct 25, 2019 for John M. * * Written by Ahmad Nejrabi for Roboja Video, www.Robojax.com * Date: Dec 14, 2017, in Ajax, Ontario, Canada * Permission granted to share this code given that this * note is kept with the code. * Disclaimer: this code is "AS IS" and for educational purpose only. * * */
const int ONTime =4000;// time for Fade ON const int OFFTime = 4000;// Time for Fade OFF int pbuttonPin = 2;// connect output to push button int LEDPin = 3;// Connected to (LED) this must PWM enabled pin that has "~" beside it
int val = 0; // push value from pin 2 int lightON = 0;//light status int pushed = 0;//push status
void setup() { // Robojax.com code and video tutorial for push button ON and OFF Serial.begin(9600); pinMode(pbuttonPin, INPUT_PULLUP); pinMode(LEDPin, OUTPUT); digitalWrite(relayPin, LOW);// keep the LED OFF initially }
void loop() { // Robojax.com code and video tutorial for push button ON and OFF val = digitalRead(pbuttonPin);// read the push button value
if(val == HIGH && lightON == LOW){
pushed = 1-pushed; delay(100); }
lightON = val;
if(pushed == HIGH){ Serial.println("LED fading ON"); doFadeON();// fade ON
// Robojax.com code and video tutorial for push button ON and OFF
delay(100); }
/* Written by Ahmad Shamshiri This funciton fades ON an LED to ONTime */ void doFadeON() { int step =ONTime/255; for(int i=0; i<255; i +=step) { analogwrite(relayPin, i); delay(255) }
Hocam bence yanılıyorsunuz, bunun iki butonla da yapılabileceği kanısındayım. Çok yeniyim ama bşr butona basınca sistem başlıcak, diğer buton A basınca kapatma zaten basit bir sistem,
Tek butonlu bir devrenin röle ile beslediği bir sistem, butona basınca, normalde çalışan röle 1sn kapanacak ve tekrar çalışacak, tekrar basınca da röle kapanacak ve sisteme elektrik gitmeyecek, öyle mi ?
Yukarıdaki sitenin en altındaki kod bu, devreyi de sitedeki gibi yaparsan çalışacaktır, kullanacak olduğun pinlerin numarasını yazmayı unutma, buradaki 6, 7 ve 13
butona basınca role 1 sn çekip bırakmasını ve bir daha butona basınca sistemin durmasını istiyorum
Youtube da araştırdım bulamadım.
Sadece butonla çalıştırma ve kapatma sistemi var.
/*
* This is the Arduino code for push button to push Fade ON and Push Fade OFF a and LED
*
* Original code was to turn ON and OFF AC bulbe. watch video instruction on video
* Be carefull working with AC is dangrous. Disconnect from AC power when working and wear protective gloves when touch the AC components.
Update Oct 25, 2019 for John M.
*
* Written by Ahmad Nejrabi for Roboja Video, www.Robojax.com
* Date: Dec 14, 2017, in Ajax, Ontario, Canada
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purpose only.
*
*
*/
const int ONTime =4000;// time for Fade ON
const int OFFTime = 4000;// Time for Fade OFF
int pbuttonPin = 2;// connect output to push button
int LEDPin = 3;// Connected to (LED) this must PWM enabled pin that has "~" beside it
int val = 0; // push value from pin 2
int lightON = 0;//light status
int pushed = 0;//push status
void setup() {
// Robojax.com code and video tutorial for push button ON and OFF
Serial.begin(9600);
pinMode(pbuttonPin, INPUT_PULLUP);
pinMode(LEDPin, OUTPUT);
digitalWrite(relayPin, LOW);// keep the LED OFF initially
}
void loop() {
// Robojax.com code and video tutorial for push button ON and OFF
val = digitalRead(pbuttonPin);// read the push button value
if(val == HIGH && lightON == LOW){
pushed = 1-pushed;
delay(100);
}
lightON = val;
if(pushed == HIGH){
Serial.println("LED fading ON");
doFadeON();// fade ON
}else{
Serial.println("LED fading OFF");
doFadeOFF();
}
// Robojax.com code and video tutorial for push button ON and OFF
delay(100);
}
/*
Written by Ahmad Shamshiri
This funciton fades ON an LED to ONTime
*/
void doFadeON()
{
int step =ONTime/255;
for(int i=0; i<255; i +=step)
{
analogwrite(relayPin, i);
delay(255)
}
}
/*
Written by Ahmad Shamshiri
This funciton fades OFF an LED to OFFTime
*/
void doFadeOFF()
{
int step =OFFTimeTime/255;//
for(int i=255; i>0; i -=step)
{
analogwrite(relayPin, i);
delay(255);
}
https://robojax.com/learn/arduino//
https://www.youtube.com/watch?v=7CCSRs5bvH0&feature=youtu.be
Bu kodun neresine butona basınca rolenin 1 sn çekip 3 saniye beklemesini ekleyebilirim
< Bu mesaj bu kişi tarafından değiştirildi ftekinsen -- 9 Ekim 2021; 12:36:39 >