» »

Arduino "leteče luči"

Arduino "leteče luči"

Mikron ::

Po dolgem času sem iz police vzel enega od svojih Arduino uno R3 krmilnika iz njega obrisal prah in začel čarat :).
Zamislil sem si LED leteče luči - takšne da bi jih lahko krmilil z dvema tipkama. Z eno tipko bi spreminjal vrsto utripanja, z drugo pa hitrost.
Vezje: Na pin2 sem preko pulldown upora vezal tipko za spremembo vrste utripanja (se pravi da ob pritisku tipke na vezje dobim logično 1 drugače je 0). Enako sem vezal tipko na pin3 za spremembo hitrosti. Na pine 4 do 13 sem vezal preko uporov LED diode.
Nisem še zelo vešč programiranja in sem spisal naslednjo kodo:
const int PRGpin = 2;
const int SPDpin = 3;
const int led1Pin = 4;
const int led2Pin = 5;
const int led3Pin = 6;
const int led4Pin = 7;
const int led5Pin = 8;
const int led6Pin = 9;
const int led7Pin = 10;
const int led8Pin = 11;
const int led9Pin = 12;
const int led10Pin = 13;

int PRGcount = 1;
int SPDcount = 100;

int PRGbut = 0;
int SPDbut = 0;

void setup() {
  Serial.begin(9600); //Samo za test
  pinMode(PRGpin, INPUT);
  pinMode(SPDpin, INPUT);
  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  pinMode(led3Pin, OUTPUT);
  pinMode(led4Pin, OUTPUT);
  pinMode(led5Pin, OUTPUT);
  pinMode(led6Pin, OUTPUT);
  pinMode(led7Pin, OUTPUT);
  pinMode(led8Pin, OUTPUT);
  pinMode(led9Pin, OUTPUT);
  pinMode(led10Pin, OUTPUT);
}

void loop() {
  PRGbut = digitalRead(PRGpin);
  SPDbut = digitalRead(SPDpin);

  if (PRGbut == HIGH) {
    PRGcount = (PRGcount + 1);
    if (PRGcount >= 4) {
      PRGcount = 1;
    }
  }

  if (SPDbut == HIGH) {
    SPDcount = (SPDcount + 100);
    if (SPDcount >= 1001) {
      SPDcount = 100;
    }
  }

  Serial.println("Program = " );//Samo za test
  Serial.println(PRGcount);//Samo za test
  Serial.println("Gumb PRG = " );//Samo za test
  Serial.println(PRGbut);//Samo za test
  Serial.println("\Hitrost = ");//Samo za test
  Serial.println(SPDcount);//Samo za test
  Serial.println("Gumb SPD=");//Samo za test
  Serial.println(SPDbut);//Samo za test
  Serial.println("*********************************");//Samo za test
  delay (1000);//Samo za test*/

  //111111111111111111111111111111111111111///
  if (PRGcount = 1) {
    digitalWrite(led1Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led1Pin, LOW);
    digitalWrite(led2Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led2Pin, LOW);
    digitalWrite(led3Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led3Pin, LOW);
    digitalWrite(led4Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led4Pin, LOW);
    digitalWrite(led5Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led5Pin, LOW);
    digitalWrite(led6Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led6Pin, LOW);
    digitalWrite(led7Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led7Pin, LOW);
    digitalWrite(led8Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led8Pin, LOW);
    digitalWrite(led9Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led9Pin, LOW);
    digitalWrite(led10Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led10Pin, LOW);
  }
  //222222222222222222222222222222222222222222222//
  if (PRGcount = 2) {
    digitalWrite(led10Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led10Pin, LOW);
    digitalWrite(led9Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led9Pin, LOW);
    digitalWrite(led8Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led8Pin, LOW);
    digitalWrite(led7Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led7Pin, LOW);
    digitalWrite(led6Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led6Pin, LOW);
    digitalWrite(led5Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led5Pin, LOW);
    digitalWrite(led4Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led4Pin, LOW);
    digitalWrite(led3Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led3Pin, LOW);
    digitalWrite(led2Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led2Pin, LOW);
    digitalWrite(led1Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led1Pin, LOW);
  }
  //33333333333333333333333333333333333333//
  if (PRGcount = 3) {
    digitalWrite(led1Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led1Pin, LOW);
    digitalWrite(led2Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led2Pin, LOW);
    digitalWrite(led3Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led3Pin, LOW);
    digitalWrite(led4Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led4Pin, LOW);
    digitalWrite(led5Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led5Pin, LOW);
    digitalWrite(led6Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led6Pin, LOW);
    digitalWrite(led7Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led7Pin, LOW);
    digitalWrite(led8Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led8Pin, LOW);
    digitalWrite(led9Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led9Pin, LOW);
    digitalWrite(led10Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led10Pin, LOW);
    //obrat//
    digitalWrite(led9Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led9Pin, LOW);
    digitalWrite(led8Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led8Pin, LOW);
    digitalWrite(led7Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led7Pin, LOW);
    digitalWrite(led6Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led6Pin, LOW);
    digitalWrite(led5Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led5Pin, LOW);
    digitalWrite(led4Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led4Pin, LOW);
    digitalWrite(led3Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led3Pin, LOW);
    digitalWrite(led2Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led2Pin, LOW);
    digitalWrite(led1Pin, HIGH);
    delay(SPDcount);
    digitalWrite(led1Pin, LOW);
  }
}


Tipka za hitrost deluje in se delay res za vsak cikel poveča za 100ms med tem ko se program utripanja vedno nastavi na 3 oziroma če držim tipko 1 pritisnjeno se nastavi na 1.
Zanima me tudi kako tipke narediti bolj odzivne, da jih ni treba držati pritisnjene da se loop odvrti ampak da bi se željeno spremenilo takoj ko pritisnem tipko.

Tole so odčitki serijskega vmesnika:

Program =
1
Gumb PRG =
0
Hitrost =
100
Gumb SPD=
0
*********************************
Program =
3
Gumb PRG =
0
Hitrost =
100
Gumb SPD=
0
********************************
Program =
1
Gumb PRG =
1
Hitrost =
100
Gumb SPD=
0
********************************
Program =
3
Gumb PRG =
0
Hitrost =
200
Gumb SPD=
1
********************************

Že v naprej se zahvaljujem za odgovore.

Highlag ::

Magična beseda je prekinitev. Ne poznam arduinota, samo povsod drugje se to izvede s tem.
Tipka mora biti vezana na pin, ki lahko sproži prekinitev, v prekinitvi pa odločitev v katero vejo bo program skočil ko pritisneš tipko.
Never trust a computer you can't throw out a window

Mikron ::

Mislim da ne, vzorce utripanja led diod je potrebno shranit zunaj programa in potem v sami zanki izbrani vzorec predvajat in stalno preverjat logično stanje tipk.

Predelujem in testiram tole kodo: (Bila je pisana za 5 ledic in sem je nekaj že popravil. Nima možnosti nastavitve hitrosti, kar bom poskusil nekako pripisat.)
#define LEDS 10

/* This array of arrays contains the led configuration for the different patterns. */
unsigned int pattern_data[19][LEDS] = {
 { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },   //Off pattern
 /***/
 { HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //Sequence pattern step 1 of 5
 { LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //Sequence pattern step 2 of 5
 { LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //Sequence pattern step 3 of 5
 { LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW },  //Sequence pattern step 4 of 5
 { LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW },  //Sequence pattern step 5 of 5
 { LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW },  //Sequence pattern step 1 of 5
 { LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW },  //Sequence pattern step 2 of 5
 { LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW },  //Sequence pattern step 3 of 5
 { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW },  //Sequence pattern step 4 of 5
 { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH },  //Sequence pattern step 5 of 5
 /***/
 { HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW}, //Alternate pattern step 1 of 2
 { LOW, HIGH, LOW, HIGH, LOW},  //Alternate pattern step 2 of 2
 /***/
 { HIGH, LOW, LOW, LOW, HIGH},  //In pattern step 1 of 3
 { LOW, HIGH, LOW, HIGH, LOW},  //In pattern step 2 of 3
 { LOW, LOW, HIGH, LOW, LOW},   //In pattern step 3 of 3
 /***/
 { LOW, LOW, HIGH, LOW, LOW},   //Out pattern step 1 of 3
 { LOW, HIGH, LOW, HIGH, LOW},  //Out pattern step 2 of 3
 { HIGH, LOW, LOW, LOW, HIGH}   //Out pattern step 3 of 3
};

/* This array contains the start and end indexes for the led configuration 
   described in the pattern_data array corresponding to a given pattern. */
unsigned int patterns[5][2] = {
  {0, 0},  // Start, end index for the Off pattern data
  {1, 10},  // Start, end index for the Sequence pattern data
  {6, 7},  // Start, end index for the Alternate pattern data
  {8, 10}, // Start, end index for the In pattern data
  {11, 13} // Start, end index for the Out pattern data
};

/* Pin configuration. */
const unsigned int button_pin = 2;
const unsigned int led_pins[LEDS] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

unsigned int current_pattern = 0;

/* Delay to be waited before changing the pattern configuration. */
const unsigned int delay_length = 200;

/* Used to avoid to repeatedly change the state if the button is kept pressed */
unsigned int current_pattern_changed;

unsigned int counter;

/******************************************************************************/

void setup() {
  Serial.begin(9600);
  
  pinMode(button_pin, INPUT);

  for(int i = 0; i < LEDS; i++) {
    pinMode(led_pins[i], OUTPUT);
  }

  Serial.println("Arduino led fun initialized.");
}

/******************************************************************************/

void loop() {
  int button_state = digitalRead(button_pin);
    
  /* Check button state */
  if(button_state == LOW) {
    /* This checks prevents to change repeatedly the pattern if the button is
       pressed for a long time */
    if(current_pattern_changed == 0) {
      current_pattern = (current_pattern + 1) % (sizeof(patterns) / sizeof(patterns[0]));
    }
    
    current_pattern_changed = 1;
  }
  else {
    current_pattern_changed = 0;
  }
  
  /* Find the pattern start and end index in the pattern data */
  unsigned int pattern_start_index = patterns[current_pattern][0];
  unsigned int pattern_end_index = patterns[current_pattern][1];

  /* Compute how many steps the pattern has */
  unsigned int steps_in_current_pattern = pattern_end_index - pattern_start_index + 1;

  /* Find the current step based on the counter */
  unsigned int current_step = counter % steps_in_current_pattern;
  
  /* Get the led configuration for the current step */
  unsigned int *led_configuration = pattern_data[pattern_start_index + current_step];
  
  /* Write the led configuration for the current pattern step */
  for(int i = 0; i < LEDS; i++) {
    digitalWrite(led_pins[i], led_configuration[i]);
  }
     
  /* Next iteration */
  counter++;
  
  delay(delay_length);
}

Mikron ::

Uspelo mi je - morda sem se prehitro vdal oz. moral o tem samo glasno razmišljat na forumu :). Kakorkoli, še vedno je tema lahko odprta za kakšne bistroumne izboljšave. Hvala in lp!

Še delujoča koda:
#define LEDS 10

unsigned int pattern_data[50][LEDS] = {
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },   //Off
  /***/
  { HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //1
  { LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //2
  { LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //3
  { LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW },  //4
  { LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW },  //5
  { LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW },  //6
  { LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW },  //7
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW },  //8
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW },  //9
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH },  //10
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW },  //11
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW },  //12
  { LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW },  //13
  { LOW, LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW },  //14
  { LOW, LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW },  //15
  { LOW, LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW },  //16
  { LOW, LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //17
  { LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //18
  /***/
  { HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW}, //19
  { LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH},  //20
  /***/
  { HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH },  //21
  { LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW },  //22
  { LOW, LOW, HIGH, LOW, LOW, LOW, LOW, HIGH, LOW, LOW },  //23
  { LOW, LOW, LOW, HIGH, LOW, LOW, HIGH, LOW, LOW, LOW },  //24
  { LOW, LOW, LOW, LOW, HIGH, HIGH, LOW, LOW, LOW, LOW },  //25
  { LOW, LOW, LOW, HIGH, LOW, LOW, HIGH, LOW, LOW, LOW },  //26
  { LOW, LOW, HIGH, LOW, LOW, LOW, LOW, HIGH, LOW, LOW },  //27
  { LOW, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW },  //28
  { HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH },  //29
  /***/
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //30
  { HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //31
  { HIGH, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //32
  { HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW, LOW, LOW },  //33
  { HIGH, HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW, LOW },  //35
  { HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW },  //35
  { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW },  //36
  { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW, LOW },  //37
  { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW },  //38
  { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW },  //39
  { HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH },  //40
  { LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH },  //41
  { LOW, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH },  //42
  { LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH },  //43
  { LOW, LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH },  //44
  { LOW, LOW, LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH, HIGH },  //45
  { LOW, LOW, LOW, LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH },  //46
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, HIGH, HIGH },  //47
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH, HIGH },  //48
  { LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW, HIGH },  //49
};

unsigned int patterns[5][2] = {
  {0, 0},
  {1, 18},
  {19, 20},
  {21, 29},
  {30, 49}
};

const unsigned int button_pin = 2;
const unsigned int spd_pin = 3;
const unsigned int led_pins[LEDS] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

unsigned int current_pattern = 0;

int delay_length = 100;

unsigned int current_pattern_changed;

unsigned int counter;

void setup() {

  pinMode(button_pin, INPUT);
  pinMode(spd_pin, INPUT);

  for (int i = 0; i < LEDS; i++) {
    pinMode(led_pins[i], OUTPUT);
  }
}

void loop() {
  int button_state = digitalRead(button_pin);
  int spd_state = digitalRead(spd_pin);
  if (spd_state == HIGH) {
    delay_length = (delay_length + 100);
    if (delay_length >= 1001) {
      delay_length = 100;
    }
  }

  if (button_state == LOW) {

    if (current_pattern_changed == 0) {
      current_pattern = (current_pattern + 1) % (sizeof(patterns) / sizeof(patterns[0]));
    }

    current_pattern_changed = 1;
  }
  else {
    current_pattern_changed = 0;
  }

  unsigned int pattern_start_index = patterns[current_pattern][0];
  unsigned int pattern_end_index = patterns[current_pattern][1];

  unsigned int steps_in_current_pattern = pattern_end_index - pattern_start_index + 1;

  unsigned int current_step = counter % steps_in_current_pattern;

  unsigned int *led_configuration = pattern_data[pattern_start_index + current_step];

  for (int i = 0; i < LEDS; i++) {
    digitalWrite(led_pins[i], led_configuration[i]);
  }

  counter++;

  delay(delay_length);
}

stalker ::

Bolj odzivno bi bilo z interrupt funkcijo. Ampak pri tako kratki loop() funkciji je za opazovalca nepomembno.
https://www.arduino.cc/en/Reference/Att...

Zgodovina sprememb…

  • spremenilo: stalker ()

Mikron ::

Še načrt:
 Načrt vezave

Načrt vezave



@stalker problem je ker se režim utripanja spremeni samo enkrat, ne glede na to kako dolgo držim tipko pritisnjeno. Hitrost se pa spreminja z vsakim loopom. V kodi ki sem jo predelal je vrstica:
/* This checks prevents to change repeatedly the pattern if the button is
       pressed for a long time */
    if(current_pattern_changed == 0) {
      current_pattern = (current_pattern + 1) % (sizeof(patterns) / sizeof(patterns[0]));
    }  
    current_pattern_changed = 1;
  }
  else {
    current_pattern_changed = 0;
  }


Nekaj podobnega bi moral narediti tudi pri gumbu za hitrost. Trenutno imam samo to:
  int spd_state = digitalRead(spd_pin);
  if (spd_state == HIGH) {
    delay_length = (delay_length + 100);
    if (delay_length >= 1001) {
      delay_length = 100;
    }
  }

zrataj4201 ::

Imam eno težavo, ki bi jo rad rešil z arduinom, pa ne znam programiranja.Mi morda lahko kdo pomaga?
Rad bi izdelal nekaj takšnega, kot je na videu. Vse razen programiranja ni problema.



Hvala.

zrataj4201 ::

Očitno ni nikogar, ki bi to storil, torej sem kupil knjigo za začetek in kaj zdaj?

Naj nabavim uno ali je je programiranje enako z vsemi Arduinoti? Naj kupim UNO ali MEGA, ki ga kasneje lahko bolje uporabim? Morda za konkreten link in pa driverje, da bi ne že začetek postal kmalu tudi konec.
Elektrika je moje področje a žal ne programiranje.
Hvala.

stalker ::

Programiranje je enako za vse Arduine, nabavi si za začetek UNO, tukaj imaš nekaj začetniških vaj: https://learn.adafruit.com/series/learn...

KraitPay ::

Tisto zgoraj bi problem nič sprogramirati.
Enostavno uporabiš en DC motorček, ki ga krmiliš preko tranzistorskega mostiča oz. če je motor močnejši kar preko MOSFETOV. Uporabiš lahko tudi H pridge čip.
Torej smer moreš menjat zaradi tega, da dobiš vrata gor/dol.

Nujno moraš imeti še dva končna stikala, s katerima omejiš gibanje.

kodiraš lahko nekako takole.

if ((motor) && (motor_končnostikalo))
{
motor = false;
}
else
{motor = true;}

Tole je pač primer enega takšnega giba. če je motor == 1, potem gre motor dol, če je 0, gre gor ali pa je v izhodišču. Rešitev je ogromno

zrataj4201 ::

Sam motor je najmanjši problem.Rabil bi relejni rfid modul. Povsod so vsi samo za povezavo z arduinom.

Tole:
http://www.dx.com/p/125khz-programmable...

in pa sprejemnik, ki vleče okoli 15 do 30cm in relejni izhod. Ostalo lahko rešima sam z releji in tajmerji, stikali.....

KraitPay ::

rfid ki vleče 30cm? saj se hecaš?

zrataj4201 ::

Sem nekje našel sprejemnik, ki vleče 50cm, a je žal zopet za arduno.

zrataj4201 ::

Sem našel RFID modul, z lasnim mikroprocesorjem, preklaplja direktni rele in dodajanje in brisanje uporabnikov je na podlagi mostičev. Pa če antena je na 20-30cm vodniku. Idealno zame. Tako bo 3 cm maksimalna odaljenost. Naj bi pa deloval nekje do 10cm. Ostalo bom rešil z časovnikiom in stikali.
KraitPay hvala ti vseeno za pomoč.

Če bo še kdo potreboval.
Menjava smeri je enostavna z relejem. Ko gre gor je delovni, ko pa dol pa merni kontakt(torej vedno vklopljen dol). Za izklop motorjev pa sta dva končna stikala; zgoraj in spodaj. Časovni rele pa zakasni spuščanje za 10-20 sekund.


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Merjenje prevodnosti vode?

Oddelek: Elektrotehnika in elektronika
192716 (1871) Ribič
»

Arduino kot časovni rele

Oddelek: Pomoč in nasveti
81466 (1052) davor92
»

Pomoč C++

Oddelek: Pomoč in nasveti
71231 (950) samo111
»

Arduino in luči (strani: 1 2 )

Oddelek: Elektrotehnika in elektronika
9811250 (8876) FX6300B
»

Testiranje Switcha

Oddelek: Strojna oprema
151771 (1427) Goldee

Več podobnih tem