だから私は近くにいると思いますが、壁にぶつかりました。私が達成しようとしていることは次のとおりです。クリック数をカウントするプログラムがあり、値が更新されるたびにシリアルデータをArduino(UNO)に送信します。
これまでのところ、私は次の作業を行っています:-LEDディスプレイでマーキーをスクロールする(Freetronicsから-http ://www.freetronics.com/products/dot-matrix-display-32x16-red#.UOBeKInjmdM)-新しい書き込みを行うPythonスクリプトシリアル経由でArduinoにデータを送信(PySerialを使用)-そして、Arduinoはシリアルモニターでデータを正しく受信しています...
だから私の問題は、LEDディスプレイに書き込むことができないということです。助けてください!
これが私のコードです:
import serial
import argparse
myserial = serial.Serial('/dev/tty.usbmodemfd121', 9600)
parser = argparse.ArgumentParser(description='Example with non-optional arguments')
parser.add_argument('count', action="store", type=str)
results = parser.parse_args()
count = results.count
message = "total clicks: " + count
print message
myserial.write(message)
例:$ python app.py 200
これにより、「合計クリック数:200」がArduinoに送信されます
そして、これが私のArduinoスケッチです:
/*
Scrolling text demonstration sketch for Freetronics DMD.
See http://www.freetronics.com/dmd for resources and a getting started guide.
Note that the DMD library uses the SPI port for the fastest, low overhead writing to the
display. Keep an eye on conflicts if there are any other devices running from the same
SPI port, and that the chip select on those devices is correctly set to be inactive
when the DMD is being written to.
*/
// you always need the code from here...........
#include <DMD.h> // for DMD
#include <SPI.h> // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include "Arial_14.h"
#define DISPLAYS_ACROSS 1 // change to 2 for two screens, etc.
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN); // creates instance of DMD to refer to in sketch
char message[] = "test string to be updated";
char serIn; //var that will hold the bytes in read from the serialBuffer
void ScanDMD() // necessary interrupt handler for refresh scanning of DMD
{
dmd.scanDisplayBySPI();
}
void setup()
{
//initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
Serial.begin(9600);
}
void loop()
{
// only if there are bytes in the serial buffer execute the following code
if(Serial.available()) {
//keep reading and printing from serial untill there are bytes in the serial buffer
while (Serial.available()>0){
serIn = Serial.read(); //read Serial
Serial.write( byte(serIn));
}
//the serial buffer is over just go to the line (or pass your favorite stop char)
Serial.println();
}
// Now I want to write the Serial message ti the DMD Disply
dmd.selectFont(Arial_Black_16);
// the text in the quotes in the next line will be scrolled across the display(s).
// message writes the TEST message above, but I want it to write serIn variable (serial data)
dmd.drawMarquee(message,strlen(message),(32*DISPLAYS_ACROSS)-1,0);
// THIS IS WHAT I WANT, but I get this error "invalid conversion from 'char' to 'const char*'"
//dmd.drawMarquee(serIn,strlen(serIn),(32*DISPLAYS_ACROSS)-1,0);
long start=millis();
long timer=start;
boolean ret=false;
while(!ret){
if ((timer+30) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
delay(100);
}
私が遭遇し続けるエラーdmd.drawMarquee()
は、最初のパラメーターを文字列として受け取ることです。C++については何も知らないので、データ型を台無しにしていると思います。
どんな助けでも大歓迎です。