что должна выдавать на com порт ардуинка, если в нее зашить сле. код

Тема в разделе "Arduino & Shields", создана пользователем Makhonin, 10 июн 2012.

  1. Makhonin

    Makhonin Гик

    #include <SoftwareSerial.h>

    SoftwareSerial mySerial(2, 3);

    void setup()
    {
    Serial.begin(57600);
    Serial.println("Goodnight moon!");

    // set the data rate for the SoftwareSerial port
    mySerial.begin(4800);
    mySerial.println("Hello, world?");
    }

    void loop() // run over and over
    {
    if (mySerial.available())
    Serial.write(mySerial.read());
    if (Serial.available())
    mySerial.write(Serial.read());
    }
     
  2. NewBot

    NewBot Нуб

    При подключении (установки коннекта) будет выводить в порт один раз Goodnight moon! и/или Hello, world?
    самый верный способ - воткнуть и проверить...
     
  3. Makhonin

    Makhonin Гик

    У меня выводит просто GoodMoon и все. Дальше, чтобы я не вводил с клавиатуры, ничего больше не выводится. Тогда я не понимаю смысл softwareserial. Я не могу понять, как он работает. У меня есть bluetooth shield и gprs shield, и работа с ними происходит как раз через эту библиотеку, но shield-ы ничего не отвечают, как и этот код.
     
  4. NewBot

    NewBot Нуб

  5. Makhonin

    Makhonin Гик

    /* SparkFun Cellular Shield - Pass-Through Sample Sketch
    SparkFun Electronics Written by Ryan Owens CC by v3.0 3/8/10
    Thanks to Ryan Owens and Sparkfun for sketch */
    #include <NewSoftSerial.h> //Include the NewSoftSerial library to send serial commands to the cellular module.
    #include <string.h> //Used for string manipulations
    char incoming_char=0; //Will hold the incoming character from the Serial Port.
    NewSoftSerial cell(7,8); //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.
    void setup()
    {
    //Initialize serial ports for communication.
    Serial.begin(9600);
    cell.begin(9600);
    Serial.println("Starting SM5100B Communication...");
    }
    void loop()
    {
    //If a character comes in from the cellular module...
    if(cell.available() >0)
    {
    incoming_char=cell.read(); //Get the character from the cellular serial port.
    Serial.print(incoming_char); //Print the incoming character to the terminal.
    }
    //If a character is coming from the terminal to the Arduino...
    if(Serial.available() >0)
    {
    incoming_char=Serial.read(); //Get the character coming from the terminal
    cell.print(incoming_char); //Send the character to the cellular module.
    }
    }
    На вот такой код после Starting SM5100B Communication... в сериал пишется ÿÿÿÿÿÿÿÿ
     
  6. NewBot

    NewBot Нуб

    У вас из cell или Serial сваливается значене 255 (ÿ = 255 из аски) если отключать и подключать "устройство в "нагорячую"" на 7,8 порту, значение меняется?