Проблема с выводом в serial

s1981
Offline
Зарегистрирован: 22.12.2013

Уважаемые форумчане помогите разобраться с проблемой. При выводе в порт получаю всякую хрень...

Драйвера стоят CH341SER (nano китайская) в мониторе порта 9600.

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Выводит всякую хрень. Типа "?х???хххх?хх"

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

а в самом мониторе порта внизу справа скорость 9600 выставил?

s1981
Offline
Зарегистрирован: 22.12.2013

ua6em пишет:

а в самом мониторе порта внизу справа скорость 9600 выставил?

Да

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

а ардуина какая?

s1981
Offline
Зарегистрирован: 22.12.2013

ua6em пишет:

а ардуина какая?

nano 3.0/328p (с алика)

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

s1981 пишет:

ua6em пишет:

а ардуина какая?

nano 3.0/328p (с алика)

этот код попробуй, что пишет?
 

/ constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  Serial.begin(9600);
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
      Serial.println("LED is ON");
    } else {
      ledState = LOW;
      Serial.println("LED is OFF");
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

 

s1981
Offline
Зарегистрирован: 22.12.2013

ua6em пишет:

s1981 пишет:

ua6em пишет:

а ардуина какая?

nano 3.0/328p (с алика)

этот код попробуй, что пишет?
 

/ constants won't change. Used here to set a pin number:
const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  Serial.begin(9600);
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the difference
  // between the current time and last time you blinked the LED is bigger than
  // the interval at which you want to blink the LED.
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
      Serial.println("LED is ON");
    } else {
      ledState = LOW;
      Serial.println("LED is OFF");
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

 

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

отфотографируй свою ардуино, что-то тут не то...

s1981
Offline
Зарегистрирован: 22.12.2013

ua6em пишет:

отфотографируй свою ардуино, что-то тут не то...

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016
s1981
Offline
Зарегистрирован: 22.12.2013

Все сделал!!! Спасибо огромное за помощь. Сам бы хрен допер)))

 

b707
Offline
Зарегистрирован: 26.05.2017

s1981 пишет:

Все сделал!!! Спасибо огромное за помощь. Сам бы хрен допер)))

 

на будущее - это не ардуина, это вавгат.

ua6em
ua6em аватар
Offline
Зарегистрирован: 17.08.2016

b707 пишет:

s1981 пишет:

Все сделал!!! Спасибо огромное за помощь. Сам бы хрен допер)))

 

на будущее - это не ардуина, это вавгат.

не, ты не прав, это ардуино на чипе WAVGAT )))

BOOM
BOOM аватар
Offline
Зарегистрирован: 14.11.2018

А я вот ни разу такую бяку не покупал. Что там за чип специфический такой стоит? Какая-то копия атмела?

b707
Offline
Зарегистрирован: 26.05.2017

BOOM пишет:

А я вот ни разу такую бяку не покупал. Что там за чип специфический такой стоит? Какая-то копия атмела?

тут есть отдельная тема по нему https://arduino.ru/forum/apparatnye-voprosy/obzor-klona-megi328-lgt8f328p