Joistik ile led yakmak

Öncelikle Merhaba ;

Joistik ile led yakma çalışması yapıyorum.Ledleri istediğim yönde yakıyorum fakat joistik kolunu bıraktığım zaman led sönüyor.Ben ise joistiğin tek yönüne (son noktasına) bir kere basıp bırakıldığı zaman,joistiği bıraksamda led yanmaya devam etsin istiyorum ve söndürürkende aynı yöne aynı hareketi yapayım ve led sönsün.

İf komutu kullanarak joistikle led yaktım. Destek olabilirmisiniz?

english, german, russian?

ingilizce.

Turkish:
"Hello first of all;

I'm working on turning on the led with the joystick. I light the leds in the direction I want, but when I release the joystick, the led turns off. On the other hand, when I press and release one direction of the joystick (last point) once, I want the led to continue to light even if I release the joystick. let it go out.

I lit the led with the joystick using the if command. Can you support? "

show your sketch, use code tag </> pls

const int ch4=A1;
int leddeger;
int A1_digital_deger=0;

void setup () {
Serial.begin (9600);
pinMode (ch4,İNPUT);
pinMode (8,OUTPUT);
}
void loop () {
A1_digital_deger=analogRead (A1);
leddeger=pulseIn (ch4,HIGH);
if (leddeger<0&&leddeger>1100)leddeger=250;

if (leddeger>250)
digitalWrite (8,LOW);

if (leddeger>1023)
digitalWrite (8,HIGH);
Serial.print ("Ch4:");
Serial.print (leddeger);

@kolaha ;Bu yazdığım kod ile joistik butonunun tek tarafında sonuna bastığım zaman led yanıyor ve bıraktığım zaman sönüyor. Ben ise joistiği bıraktığım zaman da yanmasını ve tekrar aynı işlemi yapıp sönmesini istiyorum.

const int ch4=A1;
A1_digital_deger=analogRead (ch4);
leddeger=pulseIn (ch4,HIGH); //you waiting on Analog pin, but pulseIn() is for Digital pin.

and must be:

uint32_t leddeger; // unsigned long

this will never happen

@kolaha bilgilendirmen için teşekkür ederim.Ben biraz yeniyim :slight_smile: Dediğin komutu nasıl kullanacağım. Akış ile ilgili örnek verebilirmisin rica etsem.

if (leddeger<0&&leddeger>1100)leddeger=250;

Bu bölümü kaldırdım.

show me your schematic

@kolaha kodu toparlayayım derken dahada karıştırdım heralde.


const int ch4=A1;
uint32_t leddeger;
int A1_digital_deger=0;


void setup() {
Serial.begin(9600);
pinMode(ch4,INPUT);
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
}


void loop() 
{
A1_digital_deger=digitalRead(A1);
uint32_t leddeger;pulseIn(ch4,HIGH);

if(leddeger>1023)
digitalWrite(9,LOW);

if(leddeger<1023)
digitalWrite(9,HIGH);

Serial.print("Ch4:");
Serial.print(leddeger);
}

read manual about pulseIn

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.