在没有ttyUSB串行连接的情况下,在两个Arduino之间通过RF 433MHz传输的数据不会显示在TFT LCD1.8上

问题描述 投票:0回答:1

发送器工作正常。但是如果没有ttyUSB串行连接,接收器将无法工作。我的意思是,每当我断开PC与接收器的连接时,都不会显示从发送器获取的数据。我希望它无需外接电源的PC就可以工作。可能出了什么问题?

It shows "Not Connected" when I add an external power source disconnecting the USB plug from PC

/*
 SimpleReceive
 This sketch displays text strings received using VirtualWire
 Connect the Receiver data pin to Arduino pin 3 (default 11)
*/
#include <VirtualWire.h>
#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen

//char temperatureChar[4];
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen=VW_MAX_MESSAGE_LEN;



const int buzzer = 2; //buzzer to arduino pin 2




void setup()
{

 // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);

  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255, 255, 255);
  // set the font size
  TFTscreen.setTextSize(1);
  // write the text to the top left corner of the screen
  TFTscreen.text("Temp :\n ", 5, 5);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(2);


 pinMode(buzzer, OUTPUT); // Set buzzer - pin 2 as an output
 // Initialize the IO and ISR
 //vw_set_ptt_inverted(true); // Required for DR3100
 vw_setup(2000); // Bits per sec
 vw_rx_start(); // Start the receiver
}
void loop()
{


  if(vw_get_message(buf, &buflen)) //non-blocking
  {
    // set the font color
  TFTscreen.stroke(255, 255, 255);
  // print the sensor value
  TFTscreen.text((char *)buf, 20, 20);
  // wait for a moment
  delay(1000);
  // erase the text you just wrote
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.text((char *)buf, 20, 20);


 tone(buzzer, 2000); // Send 1KHz sound signal...
 delay(1000);

 noTone(buzzer);
 }
 else {
  // set the font color
  TFTscreen.stroke(255, 255, 0);

  TFTscreen.setTextSize(1);
  // print the sensor value
  TFTscreen.text("Not connected", 20, 20);
  // wait for a moment
  delay(500);
  // erase the text you just wrote
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.setTextSize(1);
  TFTscreen.text("Not connected", 20, 20);

       }
 }
serial-port arduino-uno tty
1个回答
0
投票

已解决。 USB电缆实际上起着天线(无线电)的作用。当我断开连接时,它将失去连接。

© www.soinside.com 2019 - 2024. All rights reserved.