Skocz do zawartości

Proszę o sprawdzenie Zegar Szachowy


skorek1989

Pomocna odpowiedź

Cześć,

Nie wiem czy w dobrym dziale, ale mam problem z zegarem szachowym  na Arduino Uno R3 z Keypad Shield D3. Zegar działa, problem pojawia się kiedy czas dojdzie do końca i napięcie z A5 powinno pójść na przekaźnik. Niestety przekaźnik ma cewkę 5V przez co nie mogę podłączyć się bezpośrednio. Niemniej jednak znalazłem rozwiązanie i używam tranzystora IIRF540N ale nie działa. Podłączyłem A5 do lewej skrajnej bramki tranzystora, GND na skrajną prawą bramkę a ze środkowej bramki pod przekaźnik, natomiast wyjście 5V z arduino do przekaźnika i nic się nie dzieje. Dodam że nie wiem dlaczego na A5 mam cały czas 2,5V bez znaczenia czy czas doszedł do końca czy odlicza. Gdzie popełniam błąd?? Czy w kodzie jest coś nie tak? Proszę o pomoc w rozwiązaniu problemu.

Jest to mój pierwszy post więc  mam nadzieje że dobrze opisałem. Poniżej załączam kod.



/*
  BOOMBA ASG
*/

#include <LiquidCrystal.h>
#include <EEPROM.h>

//defining seconds count
#define SEC (60 +(millis() / 1000))

//define keypad buttons
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

//constants
const int buttonOrange = A1;
const int buttonRed = A3;
const int pinBuzzer = A5;
const int analogPin = A0;

//Variables for keypad and menu
int lcd_key = 0;
int adc_key_in = 0;
int countMenu = 0;
int blinkTime;
int initBlinkTime;
int blinkDelay = 500;
bool exitMenu = true;
bool sidePlayer = true;
bool blinkState = true;

//Variables for seconds count
int cTemp = 0;
int cSecOrange = 0;
int cSecRed = 0;

//Increment variable
int setInc;

//Variables to Orange timer
int setSecOrange;
int horOrange;
int minOrange;
int secOrange;

//Variables to red timer
int setSecRed;
int horRed;
int minRed;
int secRed;

//LCD setup
const int rs = 8, e = 10, d4 = 4, d5 = 5, d6 = 6, d7 = 7, d9 = 9 ;
LiquidCrystal lcd(8, 1, 9, 4, 5, 6, 7);

//fix bounce of keys
void debounceKey() {
  while (adc_key_in < 1000) {
    adc_key_in = analogRead(analogPin);
  }
}

//keypad code by:
//https://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)
//read keypad buttons
int read_LCD_buttons()
{
  adc_key_in = analogRead(analogPin);      // read the value from the sensor
  // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
  // we add approx 50 to those values and check to see if we are close
  if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result

  // For V1.1 us this threshold
  /*if (adc_key_in < 50)   return btnRIGHT;
    if (adc_key_in < 250)  return btnUP;
    if (adc_key_in < 450)  return btnDOWN;
    if (adc_key_in < 650)  return btnLEFT;
    if (adc_key_in < 850)  return btnSELECT;
  */

  // For V1.0 comment the other threshold and use the one below:
  if (adc_key_in < 50)   return btnRIGHT;
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;
  return btnNONE;  // when all others fail, return this...
}

//set up menu
void menuSetUp() {

  lcd_key = read_LCD_buttons();  // read the buttons

  switch (lcd_key)               // depending on which button was pushed, we perform an action
  {
    case btnRIGHT:
      {
        countMenu++;
        if (countMenu > 4) countMenu = 0;
        debounceKey();
        break;
      }
    case btnLEFT:
      {
        countMenu--;
        if (countMenu < 0) countMenu = 4;
        debounceKey();
        break;
      }
    case btnUP:
      {
        if (countMenu == 0) { //increase hour
          horOrange++;
          if (horOrange > 9) horOrange = 0;
          debounceKey();
        }
        else if (countMenu == 1) { //increase minutes
          minOrange++;
          if (minOrange > 59) minOrange = 0;
          debounceKey();
        }
        else if (countMenu == 2) { //increase seconds
          secOrange++;
          if (secOrange > 59) secOrange = 0;
          debounceKey();
        }
        else if (countMenu == 3) { //increase increment
          setInc++;
          if (setInc > 99) setInc = 0;
          debounceKey();
        }
        else { //change OR to RO
          sidePlayer ^= 1;
          debounceKey();
        }
        break;
      }
    case btnDOWN:
      {
        if (countMenu == 0) { //decrease hour
          horOrange--;
          if (horOrange < 0) horOrange = 9;
          debounceKey();
        }
        else if (countMenu == 1) { //decrease minutes
          minOrange--;
          if (minOrange < 0) minOrange = 59;
          debounceKey();
        }
        else if (countMenu == 2) { //decrease seconds
          secOrange--;
          if (secOrange < 0) secOrange = 59;
          debounceKey();
        }
        else if (countMenu == 3) { //decrease increment
          setInc--;
          if (setInc < 0) setInc = 99;
          debounceKey();
        }
        else { //change OR to RO
          sidePlayer ^= 1;
          debounceKey();
        }
        break;
      }
    case btnSELECT: //exit set up menu
      {
        exitMenu = 0;
        break;
      }
    case btnNONE:
      {
        break;
      }
  }
}

//printing orange values to LCD and print timer to set up menu
void printTimerOrange() {

  //used to timer blink
  blinkTime = millis() - blinkDelay;

  //printing hour blinking
  //used only in set up
  if (exitMenu == 1 && countMenu == 0) {
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(0, 1);
      lcd.print(" ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      lcd.setCursor(0, 1);
      lcd.print(horOrange);
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  //printing hour withouy blink
  else {
    lcd.setCursor(0, 1);
    lcd.print(horOrange);
  }
  lcd.setCursor(1, 1);
  lcd.print(":");

  //printing minutes blinking
  //used only in set up
  if (exitMenu == 1 && countMenu == 1) {
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(2, 1);
      lcd.print("  ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      //this fix the print value below 10 moving the cursor one point and put 0 to left
      if ((minOrange < 10) && (minOrange >= 0)) {
        lcd.setCursor(2, 1);
        lcd.print(0);
        lcd.setCursor(3, 1);
        lcd.print(minOrange);
      }
      else {
        lcd.setCursor(2, 1);
        lcd.print(minOrange);
      }
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  //printing minutes without blink
  else {
    //this fix the print value below 10 moving the cursor one point and put 0 to left
    if ((minOrange < 10) && (minOrange >= 0)) {
      lcd.setCursor(2, 1);
      lcd.print(0);
      lcd.setCursor(3, 1);
      lcd.print(minOrange);
    }
    else {
      lcd.setCursor(2, 1);
      lcd.print(minOrange);
    }
  }
  lcd.setCursor(4, 1);
  lcd.print(":");

  //print seconds blinking
  //used only in set up
  if (exitMenu == 1 && countMenu == 2) {
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(5, 1);
      lcd.print("  ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      //this fix the print value below 10 moving the cursor one point and put 0 to left
      if ((secOrange < 10) && (secOrange >= 0)) {
        lcd.setCursor(5, 1);
        lcd.print(0);
        lcd.setCursor(6, 1);
        lcd.print(secOrange);
      }
      else {
        lcd.setCursor(5, 1);
        lcd.print(secOrange);
      }
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  //print seconds without blink
  else {
    //this fix the print value below 10 moving the cursor one point and put 0 to left
    if ((secOrange < 10) && (secOrange >= 0)) {
      lcd.setCursor(5, 1);
      lcd.print(0);
      lcd.setCursor(6, 1);
      lcd.print(secOrange);
    }
    else {
      lcd.setCursor(5, 1);
      lcd.print(secOrange);
    }
  }
}

//printing red values to LCD
void printTimerRed() {

  //printing hour
  lcd.setCursor(9, 1);
  lcd.print(horRed);
  lcd.setCursor(10, 1);
  lcd.print(":");

  //printing minutes
  //this fix the print value below 10 moving the cursor one point and put 0 to left
  if ((minRed < 10) && (minRed >= 0)) {
    lcd.setCursor(11, 1);
    lcd.print(0);
    lcd.setCursor(12, 1);
    lcd.print(minRed);
  }
  else {
    lcd.setCursor(11, 1);
    lcd.print(minRed);
  }
  lcd.setCursor(13, 1);
  lcd.print(":");

  //print seconds
  //this fix the print value below 10 moving the cursor one point and put 0 to left
  if ((secRed < 10) && (secRed >= 0)) {
    lcd.setCursor(14, 1);
    lcd.print(0);
    lcd.setCursor(15, 1);
    lcd.print(secRed);
  }
  else {
    lcd.setCursor(14, 1);
    lcd.print(secRed);
  }
}

//print menu set up
void printMenu() {

  lcd.setCursor(0, 0);
  lcd.print("SET UP O/ KEYPAD");
  lcd.setCursor(8, 1);
  lcd.print("Inc");

  //used to timer blink
  blinkTime = millis() - blinkDelay;

  //print increment value to set up
  if (countMenu == 3) {

    //print increment value blinking
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(11, 1);
      lcd.print("  ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      //this fix the print value below 10 moving the cursor one point and put 0 to left
      if ((setInc < 10) && (setInc >= 0)) {
        lcd.setCursor(11, 1);
        lcd.print(0);
        lcd.setCursor(12, 1);
        lcd.print(setInc);
      }
      else {
        lcd.setCursor(11, 1);
        lcd.print(setInc);
      }
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  //print increment value without blink
  else {
    //this fix the print value below 10 moving the cursor one point and put 0 to left
    if ((setInc < 10) && (setInc >= 0)) {
      lcd.setCursor(11, 1);
      lcd.print(0);
      lcd.setCursor(12, 1);
      lcd.print(setInc);
    }
    else {
      lcd.setCursor(11, 1);
      lcd.print(setInc);
    }
  }

  //print side player (OR or RO) blinking
  if (exitMenu == 1 && countMenu == 4) {
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(14, 1);
      lcd.print("  ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      if (sidePlayer == 1) {
        lcd.setCursor(14, 1);
        lcd.print("OR");
      }
      else {
        lcd.setCursor(14, 1);
        lcd.print("RO");
      }
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  //print side player (OR or RO) without blink
  else {
    if (sidePlayer == 1) {
      lcd.setCursor(14, 1);
      lcd.print("OR");
    }
    else {
      lcd.setCursor(14, 1);
      lcd.print("RO");
    }
  }
}

//printing labels
void printLabels() {

  lcd.clear();

  if (sidePlayer == 1) { //seleted in menuSetUp
    lcd.setCursor(0, 0);
    lcd.print("ORANGE");
    lcd.setCursor(11, 0);
    lcd.print("RED");
  }
  else {
    lcd.setCursor(0, 0);
    lcd.print("RED");
    lcd.setCursor(11, 0);
    lcd.print("ORANGE");
  }
  lcd.setCursor(7, 1);
  lcd.print("||");
  lcd.setCursor(6, 0);
  lcd.print("|  |");

  //this fix the print value below 10 moving the cursor one point and put 0 to left
  if ((setInc < 10) && (setInc >= 0)) {
    lcd.setCursor(7, 0);
    lcd.print(0);
    lcd.print(setInc);
    lcd.setCursor(8, 0);
  }
  else {
    lcd.setCursor(7, 0);
    lcd.print(setInc);
  }

  tone(pinBuzzer, 4300);
    delay(150);
    tone(pinBuzzer, 3500);
    delay(150);
  digitalWrite(LED_BUILTIN, LOW);

  //printing timers values
  printTimerOrange();
  printTimerRed();
}

void pauseGameOrange() {

  //with game paused in timer orange, for exit is necessary push button red
  while (digitalRead(buttonRed) == 0) {

    //used to timer blink
    blinkTime = millis() - blinkDelay;

    //print < caracter blinking
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(5, 0);
      lcd.print(" ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      lcd.setCursor(5, 0);
      lcd.print("<");
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  lcd.setCursor(5, 0);
  lcd.print(" ");
}

void pauseGameRed() {

  //with game paused in timer orange, for exit is necessary push button red
  while (digitalRead(buttonOrange) == 0) {

    //used to timer blink
    blinkTime = millis() - blinkDelay;

    //print > caracter blinking
    if (blinkTime >= initBlinkTime && blinkState == 1) {
      lcd.setCursor(10, 0);
      lcd.print(" ");
      blinkState = 0;
      initBlinkTime = millis();
    }
    if (blinkTime >= initBlinkTime && blinkState == 0) {
      lcd.setCursor(10, 0);
      lcd.print(">");
      blinkState = 1;
      initBlinkTime = millis();
    }
  }
  lcd.setCursor(10, 0);
  lcd.print(" ");
}

//running timer orange
void timerOrange() {

  //cSecOrange is a counter that will increase with millis() due SEC define.
  //The variable cSecOrange is updated in Arduino loop() (cSecOrange = SEC - cTemp).

  //seconds timer (secOrange) = seconds selected in menu set up (setSecOrange) minus
  //cSecOrange that will increase with milles() due SEC define.
  secOrange = setSecOrange - cSecOrange;

  printTimerOrange(); //update values

  //* making the timer *//
  //if seconds timer below 0(-1) and minutes >=0 plus counter seconds with 59 to
  //setSecOrange update the value and remove 1 in minutes timer
  if ((secOrange == -1) && (minOrange >= 0)) {
    setSecOrange = cSecOrange + 59; //update setSecOrange
    minOrange--;
  }
  //if seconds and minutes timer below 0(-1) and hour is > 0 plus 59 to
  //setSecOrange update the value,put minutes to 59 and remove 1 to hour
  if ((secOrange == -1) && (minOrange == -1) && (horOrange > 0)) {
    setSecOrange = cSecOrange + 59;
    minOrange = 59;
    horOrange--;
  }

  //if seconds, minutes and hour timers go to 0 loop forever and print end game
  if ((secOrange == 0) && (minOrange == 0) && (horOrange == 0)) {
    tone(pinBuzzer, 4300);
    delay(150);
    tone(pinBuzzer, 3500);
    delay(150);
    while (1) {
      lcd.setCursor(10, 0);
      lcd.print("      ");
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      lcd.setCursor(10, 0);
      lcd.print("WINNER");
      digitalWrite(LED_BUILTIN, LOW);
      delay(1000);
    }
  }
}

//running timer red
void timerRed() {

  secRed = setSecRed - cSecRed;

  printTimerRed();

  //timer
  if ((secRed == -1) && (minRed >= 0)) {
    setSecRed = cSecRed + 59;
    minRed--;
  }
  if ((secRed == -1) && (minRed == -1) && (horRed > 0)) {
    setSecRed = cSecRed + 59;
    minRed = 59;
    horRed--;
  }

  //end game
  if ((secRed == 0) && (minRed == 0) && (horRed == 0)) {
    tone(pinBuzzer, 4300);
    delay(150);
    tone(pinBuzzer, 3500);
    delay(150);
    while (1) {
      lcd.setCursor(0, 0);
      lcd.print("      ");
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      lcd.setCursor(0, 0);
      lcd.print("WINNER");
      digitalWrite(LED_BUILTIN, LOW);
      delay(1000);
    }
  }
}

//increment to orange
void incOrange() {
  if (setInc > 0) {
    secOrange = secOrange + setInc; //increment seconds to seconds timer
    cSecOrange = setSecOrange - secOrange; //start new count

    //if seconds timer + increment > 59 and < 120 add 1 to minutes and remove 60 seconds to seconds timer
    if (secOrange > 59 && secOrange < 120) {
      secOrange = secOrange - 60;
      cSecOrange = setSecOrange - secOrange;
      minOrange++;
    }
    //if seconds timer + increment > 119 add 2 to minutes and remove 120 seconds to seconds timer
    else if (secOrange > 119) {
      secOrange = secOrange - 120;
      cSecOrange = setSecOrange - secOrange;
      minOrange = minOrange + 2;
    }
    //if minutes timer > 59 add 1 to hour and remove 60 to minutes timer
    if (minOrange > 59) {
      minOrange = minOrange - 60;
      horOrange++;
    }
    printTimerOrange(); //print new values
  }
}

//increment to red
void incRed() {
  if (setInc > 0) {
    secRed = secRed + setInc;
    cSecRed = setSecRed - secRed;
    if (secRed > 59 && secRed < 120) {
      secRed = secRed - 60;
      cSecRed = setSecRed - secRed;
      minRed++;
    }
    else if (secRed > 119) {
      secRed = secRed - 120;
      cSecRed = setSecRed - secRed;
      minRed = minRed + 2;
    }
    if (minRed > 59) {
      minRed = minRed - 60;
      horRed++;
    }
    printTimerRed();
  }
}

void readEeprom() {

  //used in case Arduino was used in another aplication
  if (EEPROM.read(0) > 59) EEPROM.write(0, 0);
  if (EEPROM.read(1) > 59) EEPROM.write(1, 0);
  if (EEPROM.read(2) > 9) EEPROM.write(2, 0);
  if (EEPROM.read(3) > 99) EEPROM.write(3, 0);
  if (EEPROM.read(4) > 1) EEPROM.write(4, 1);

  //load values to variables
  secOrange = EEPROM.read(0);
  minOrange = EEPROM.read(1);
  horOrange = EEPROM.read(2);
  setInc = EEPROM.read(3);
  sidePlayer = EEPROM.read(4);
}

void writeEeprom() {

  //write values that have been selected to eeprom
  EEPROM.write(0, secOrange);
  EEPROM.write(1, minOrange);
  EEPROM.write(2, horOrange);
  EEPROM.write(3, setInc);
  EEPROM.write(4, sidePlayer);
}

//Arduino setup
void setup() {

  //setup pins
  pinMode(buttonOrange, INPUT); //button Orange
  pinMode(buttonRed, INPUT); //button Red
  pinMode(analogPin, INPUT);   //used in keypad
  pinMode(pinBuzzer, OUTPUT);  //buzzer
  pinMode(LED_BUILTIN, OUTPUT);//led pin 13

  //start LCD
  lcd.begin(16, 2);
  lcd.clear();

  //start message
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("BOOMBA ASG");
  lcd.setCursor(0, 1);
  lcd.print("Zegar Szachowy");
  delay(2000);
  lcd.clear();

  digitalWrite(LED_BUILTIN, HIGH);

  readEeprom(); //read eeprom values and load to variables

  while (exitMenu) {    //start set up menu
    menuSetUp();        //keypad set up
    printMenu();        //print menu values
    printTimerOrange(); //print setup timer in left below
  }

  writeEeprom(); //write values selected to eeprom

  //setting up values for Orange and red to start timers
  horRed = horOrange;
  minRed = minOrange;
  secRed = secOrange;
  setSecRed = secOrange;
  setSecOrange = secOrange;

  printLabels(); //printing labels
}

//Arduino loop
void loop() {

  adc_key_in = analogRead(analogPin); //read keypad

  //push red button run orange timer
  if (digitalRead(buttonRed)) {
    tone(pinBuzzer, 4300);
    delay(150);
    tone(pinBuzzer, 3500);
    delay(150);
    cTemp = SEC - cSecOrange; //difference between SEC and previous seconds count
    while (digitalRead(buttonOrange) == 0 && adc_key_in > 1000) { //if orange button or any keypad pushed exit loop
      cSecOrange = SEC - cTemp; //second count for orange timer
      timerOrange(); //run timer orange
      adc_key_in = analogRead(analogPin); //read keypad
    }
    if (adc_key_in < 1000) { //if any keypad pushed go to pause
      pauseGameOrange();
    }
    else {
      incOrange(); //increment seconds
    }
  }

  //push orange button run red timer
  if (digitalRead(buttonOrange)) {
    tone(pinBuzzer, 4300);
    delay(150);
    tone(pinBuzzer, 3500);
    delay(150);
    cTemp = SEC - cSecRed;
    while (digitalRead(buttonRed) == 0 && adc_key_in > 1000) {
      cSecRed = SEC - cTemp;
      timerRed();
      adc_key_in = analogRead(analogPin);
    }
    if (adc_key_in < 1000) {
      pauseGameRed();
    }
    else {
      incRed();
    }
  }
}

Z góry dziękuję za pomoc, proszę pisać jeśli brakuje jakiś informacji... 

Link do komentarza
Share on other sites

1 godzinę temu, skorek1989 napisał:

do lewej skrajnej bramki tranzystora, GND na skrajną prawą bramkę a ze środkowej bramki pod przekaźnik, natomiast wyjście 5V z arduino do przekaźnika i nic się nie dzieje

Pokaż schemat bo z opisu wygląda na to, że tranzystor ma  dwie bramki (są takie ale to nie IIRF540N) no i nie wiadomo co to prawa skrajnia bo zależy jak położysz tranzystor.

Link do komentarza
Share on other sites

Apropo tego kursu to w nim też powinien być zawarty schemat elektryczny układu oprócz tych obrazków. Nie chce mi się teraz wczytywać w treść. Spróbuj sam ten schemat narysować to się pozastanawiamy.

Link do komentarza
Share on other sites

Zarejestruj się lub zaloguj, aby ukryć tę reklamę.
Zarejestruj się lub zaloguj, aby ukryć tę reklamę.

jlcpcb.jpg

jlcpcb.jpg

Produkcja i montaż PCB - wybierz sprawdzone PCBWay!
   • Darmowe płytki dla studentów i projektów non-profit
   • Tylko 5$ za 10 prototypów PCB w 24 godziny
   • Usługa projektowania PCB na zlecenie
   • Montaż PCB od 30$ + bezpłatna dostawa i szablony
   • Darmowe narzędzie do podglądu plików Gerber
Zobacz również » Film z fabryki PCBWay

@skorek1989 witam na forum nowego użytkownika! Jeśli nie masz schematu i nie potrafisz go narysować to wstaw chociaż zdjęcie swojego układu - łatwiej będzie pomóc 😉

3 godziny temu, skorek1989 napisał:

Niestety przekaźnik ma cewkę 5V przez co nie mogę podłączyć się bezpośrednio.

Arduino również pracuje na 5V, więc wszystko pasuje. Potrzebny jest tylko tranzystor, który zabezpieczy Arduino przed poborem zbyt dużego prądu. Dlaczego te 5V wydawało Ci się tutaj problemem? Najłatwiej będzie podłączyć przekaźnik zgodnie ze schematami dostępnymi w tym artykule: Kurs elektroniki – #9 – elementy stykowe, przekaźniki

Link do komentarza
Share on other sites

Zrób tak - odłącz tranzystor i przekaźnik od arduino czy co to tam jest, sprawdź miernikiem jaką oporność ma cewka od przekaźnika bez podłączania zasilania bo być może masz za wielki przekaźnik i za dużo prądu ciągnie z płytki, podłącz przekaźnik do baterii bezpośrednio i sprawdź czy działa, podłącz tranzystor do przekaźnika i rezystora i na zmianę stykaj rezystor raz z + raz z - i sprawdź czy działa przełączanie, na koniec podłącz do płytki zgodnie ze schematem i jeśli nie będzie działać poszukamy błędu w programie.

Rezystor może być i 1k albo 2k nawet jaki tam masz pod ręką.

Link do komentarza
Share on other sites

7 minut temu, atMegaTona napisał:

Rezystor może być i 1k albo 2k nawet jaki tam masz pod ręką.

Po co rezystor w MOSFET? Aby wymusić określony poziom w stanie spoczynku (np po resecie) ok ale wtedy nie1 czy 2 k a raczej 10..100. W aplikacjach driverów do MOSFET jest rezystor szeregowy ale nie zawsze jest on konieczny i nie ma 1 czy 2 k tylko kilka, kilkadziesiąt ohm. Duża wartość rezystora wpływa niekorzystnie bo wraz z pojemnością bramki tworzy on filtr RC.

Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.