Всем привет. Я использую схему с последовательным соединением кнопок. Все работает. Но у меня возникли трудности с подключением кнопки troyka (c выходами SGV) в эту схему. Подскажите как она должна выглядеть и как в таком случае подключить резисторы. А это код: #define ERROR_WINDOW 50 // +/- this value #define BUTTONDELAY 20 #define DEBUG_ON int analogPin = 3; // switch circuit input connected to analog pin 3 long buttonLastChecked = 0; // variable to limit the button getting checked every cycle void setup () { Serial.begin(9600); pinMode(A3, INPUT); } void loop() { if( buttonLastChecked == 0 ) // see if this is the first time checking the buttons buttonLastChecked = millis()+BUTTONDELAY; // force a check this cycle if( millis() - buttonLastChecked > BUTTONDELAY ) { // make sure a reasonable delay passed if( int buttNum = buttonPushed(analogPin) ) { Serial.print("Button "); Serial.print(buttNum); Serial.println(" was pushed."); } buttonLastChecked = millis(); // reset the lastChecked value } } int buttonPushed(int pinNum) { int val = 0; // variable to store the read value digitalWrite((14+pinNum), HIGH); // enable the 20k internal pullup val = analogRead(pinNum); // read the input pin // we don't use the upper position because that is the same as the // all-open switch value when the internal 20K ohm pullup is enabled. //if( val >= 923 and val <= 1023 ) // Serial.println("switch 0 pressed/triggered"); if( val >= 475 and val <= 890 ) { // 830 #ifdef DEBUG_ON Serial.println("switch 1 pressed/triggered"); #endif return 1; } else if ( val >= (375-ERROR_WINDOW) and val <= (375+ERROR_WINDOW) ) { // 693 #ifdef DEBUG_ON Serial.println("switch 2 pressed/triggered"); #endif return 2; } else if ( val >= (275-ERROR_WINDOW) and val <= (275+ERROR_WINDOW) ) { // 430 #ifdef DEBUG_ON Serial.println("switch 3 pressed/triggered"); #endif return 3; } else if ( val >= (175-ERROR_WINDOW) and val <= (175+ERROR_WINDOW) ) { // 230 #ifdef DEBUG_ON Serial.println("switch 4 pressed/triggered"); #endif return 4; } else return 0; // no button found to have been pushed } Заранее спасибо!
в тройка кнопка уже стоит подтягивающий резистор 10 ком к +5вольт. G - земля V - +5 вольт S - цифровой пин При таком подключении пока кнопка не нажата - HIGH, когда кнопка нажата — LOW.
Возможно ли подключить эту кнопку, чтобы нажатие было -HIGH? Проблема в том, что кнопки соединены последовательно? Общий смысл кода, в том чтобы при нажатой кнопке на мониторе запускалось видео (каждая кнопка запускает отдельное видео) . Значение от каждой кнопки получает программа Processing, которая и запускает видео. В данном случае важно, чтобы именно нажатие включало видео.