Pushbutton: yadda ake amfani da wannan sassaukarwa mai sauki tare da Arduino

maballin

Un maballin turawa maballin ne wanda zai baka damar katsewa ko aika siginar lantarki. Tare da wannan sauƙi mai sauƙi haɗe tare da wasu abubuwa zaku iya ƙirƙirar ayyuka don yawan aikace-aikace. Amfani da irin wannan maɓallin turawa ya zama ruwan dare gama gari idan ya zo ga ayyukan tare da Arduino. Kuma ta hanyar haɗa waɗannan maɓallan da yawa zaku iya ƙirƙirar maɓallin keɓaɓɓen maɓalli, kodayake akwai maɓallan maɓallan shirye-shiryen shirye-shiryen waɗannan amfanin ...

Af bai kamata ku dame maɓallin turawa tare da sauyawa ba. Abubuwa ne daban-daban. Bambanci shine cewa an kunna ko kunna kunna tare da kowane latsa wanda aka yi akan sa. Ganin cewa maɓallin turawa zai tsaya a cikin ƙasa ɗaya kawai yayin da ake matsa lamba akan shi. Na yi sharhi cewa zai iya aikawa ko katsewa, wannan saboda akwai maɓallan maɓalli guda biyu masu mahimmanci.

alamar maballin turawa

Akwai BAYA ko buɗe buɗe maɓallin tura turare da NC ko maɓallan maballin rufewa koyaushe. Wannan kuma zai yi muku sauti daga maimaitawa. Kuma haka ne, daidai yake da aiki ɗaya. Lokacin da kake da NC, zai bar halin yanzu ya wuce ta tashoshin sa kuma yana katsewa yayin da kake latsa shi. A gefe guda, NA ba ta barin halin yanzu ya wuce lokacin da ba a matsa mata lamba ba kuma za ta bar shi ta wuce lokacin da ka matsa shi.

Sanin haka, shine kusan duk abin da kuke buƙatar sani game da maɓallin turawa don fara haɗin ku da shirye-shiryenku ta amfani da Arduino. Gaskiyar ita ce, wannan abu ne mai sauƙi wanda babu ƙarin abin da za a faɗi game da wannan nau'in maballin.

Haɗa Button Haɗawa tare da Arduino

kewaye da Arduino

La haɗa maɓallin turawa sanya shi hulɗa da Arduino ba zai iya zama mai sauƙi ba. Misali shine zane wanda zaku iya gani akan waɗannan layukan. Wannan zai zama duk abin da za a fara don gwaji. Amma tabbas, tare da wannan makircin zaka iya yin kadan. Kuna buƙatar sanya ɗan tunani don yanke shawarar abin da maballin zai sarrafa. A zahiri, idan kuna yawan karanta hwlibre.es tuni kun ga wasu labarai inda muka yi amfani da maɓallin turawa ...

Hanyoyi don haɗa shi

ja-da-ja-kasa

Abu daya da yakamata ku sani shine batun anti-billa da yadda zaka hada wadannan maballin. Da farko za mu je hanyar haɗi da su, wanda kuka riga kuka sani na iya kasancewa tare da masu adawa da andarfafawa da pullarfafawa:

  • Ja-up- Tare da wannan saitin tsayayyar, lokacin da aka danna maballin, microcontroller ko Arduino zai iya gani ko karanta sifili akan wannan fil. Wato, yana fassara shi azaman siginar KARANTA.
  • Ja-ƙasa: A wannan yanayin akasin haka ne, zaku iya karanta ko karɓar siginar 1 ko HIGH ta hanyar haɗin fil ɗin da aka haɗa.

Kada ku dame shi da NC ko NA, wanda wani abu ne daban kamar yadda muka gani a baya. Wannan mai zaman kansa ne daga ɗayan ...

Anti-Bounce

Maballin maballin yana da billa sakamako lokacin da aka matsa. Wato, lokacin da aka matsa shi ko aka sake shi akwai jujjuyawar siginar da ke wucewa ta cikin abokan hulɗarta kuma zai iya sa ta tashi daga HIGT state zuwa ROW ko akasin haka ba tare da gaske son hakan ta faru ba. Wannan na iya haifar da tasirin da ba'a so akan Arduino kuma ya sanya shi yin abubuwa masu ban mamaki, kamar kunna abun yayin da da gaske muke son kashe shi tare da maɓallin turawa, da sauransu. Wancan ne saboda Arduino yana fassara fa'idodin kamar dai an danna shi ba sau ɗaya ba ...

Wannan mummunan tasirin yana da mafita. Don wannan, dole ne a aiwatar da ƙaramin ƙarfin a cikin hanyar anti-bounce (hanyar kayan aiki) ko software (gyaggyara lambar tushe), ko anyi amfani da tsari na ja ko cirewa ko idan ta kasance NC ko NO. A duk waɗannan sharuɗɗa, dole ne a aiwatar da mafita don kauce wa waɗannan ramuwar gayya.

Misali, jawo-sama da kuma jan-kasa da'irori tare da anti-billa capacitor za su yi kama da wani abu kamar haka:

sake sakewa

Duk da yake Hanyar software Ana iya ganinta a cikin wannan lambar yanki:

idan (digitalRead (button) == LOW) // Bincika idan an danna maɓallin
{
guga man = 1; // Mai canji yana canza darajar
}
idan (digitalRead (maballin) == HIGH && an matsa == 1)
{
// Yi aikin da ake so
guga = 0; // Mai canzawa ya dawo zuwa ƙimar sa ta asali
}

Misali mai sauki

anti-billa tare da maɓallin turawa da Arduino

Da zarar mun koyi batun hanyoyin da za a haɗa makullin turawa da kewayen anti-rebound, za mu ga misali mai amfani ga sarrafa LED tare da maɓallin turawa. Makirci daidai yake da sauƙi kamar yadda kuke gani.

Da zarar an haɗa shi daidai, abu na gaba shine a rubuta lambar a cikin Arduino IDE don shirya kwamitinku kuma fara gwaji tare da maɓallan. Misali mai sauƙin lamba don sarrafa da'irarmu zai zama mai zuwa:

// Misali na zane don sarrafa maɓallin
int fil = 2;
int jihar
bugun int = 0;
rashin aikin saiti ()

{
pinMode (2, INPUT); // Don karanta bugun jini ta hanyar shigar da wannan fil ɗin

pinMode (13, FITOWA); // Ga LED

Serial. Shiga (9600);
}
mara amfani madauki ()

{
idan (digitalRead (2) == MAI Girma)

{

fil = 2;

antiBounce (); // Kira ga aikin anti-billa

}
}
// Software anti-billa aiki
wofi anti-billa ()

{
yayin (digitalRead (pin) == LOW);
jihar = digitalRead (13);
digitalWrite (13,! jihar);
yayin (dijitalRead (pin) == MAGANA);

}


Abubuwan da ke cikin labarin suna bin ka'idodinmu na ka'idojin edita. Don yin rahoton kuskure danna a nan.

3 comments, bar naka

Bar tsokaci

Your email address ba za a buga. Bukata filayen suna alama da *

*

*

  1. Mai alhakin bayanan: Miguel Ángel Gatón
  2. Dalilin bayanan: Gudanar da SPAM, gudanar da sharhi.
  3. Halacci: Yarda da yarda
  4. Sadarwar bayanan: Ba za a sanar da wasu bayanan ga wasu kamfanoni ba sai ta hanyar wajibcin doka.
  5. Ajiye bayanai: Bayanin yanar gizo wanda Occentus Networks (EU) suka dauki nauyi
  6. Hakkoki: A kowane lokaci zaka iyakance, dawo da share bayanan ka.

  1.   Marcelo Castillo mai sanya hoto m

    Sanyi !!! Na gode sosai, na kasance ina kera CNC kuma baban maɓallan sun kasance abu mafi wuya a gare ni na tune.

  2.   Liliana m

    Barka dai! Na tuntuɓe a matsayin sabon shiga, dangane da GND the ..ya kamata baƙar waya ta fito daga layin mara kyau, wanda yake sama da wanda aka nuna a zane na 2?

  3.   Giovanni m

    Kyakkyawan bayani .. shekaru biyu da suka gabata na yi aikin ƙone motar kuma gaskiyar magana ita ce ba zan iya yin jigon daidai ba. Don ƙwanƙwasawa .. Zan gwada wannan hanyar.