Announcement

Collapse
No announcement yet.

Serial Communication with Pixxi and Arduino

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serial Communication with Pixxi and Arduino

    Hello,

    I have the following script to receive Serial Commands on pixxi and the script is working when I use the UPA Board and the Workshop:

    Code:
    #platform "pixxiLCD-13P2CT-CLB"
    
    
    // Program Skeleton 1.5 generated 15/02/2021 07:43:11 p. m.
    
    // #MODE RUNFLASH uncomment and set Destination to Flash to run from Flash, refer 4D-AN-00055
    
    #inherit "4DGL_16bitColours.fnc"
    
    #inherit "VisualConst.inc"
    
    // var gradientRAM[29+xxx*2] := [-1,-1,-9999,0,0,xxx] ; // uncomment and replace xxx with maximum of all inherent 'media' widgets
    
    #inherit "SerialTestConst.inc"
    
    func readCmd()
    var cmdbuf[5];
    var dest[10];
    
    var returnbuf[10];
    var chr := 0;
    var index := 0;
    var np;
    var strOut;
    strOut:=str_Ptr(dest);
    
    while (index <= 4)
    chr := serin();
    returnbuf[index] := chr;
    if (index==0) to(strOut);
    if (index>0) to(APPEND);
    print([CHR]returnbuf[index]);
    print([CHR]chr);
    index := index + 1;
    //pause(1000);
    wend
    
    print("strOut is : ", [STR]strOut);
    
    return returnbuf;
    
    endfunc
    
    
    func main()
    // var hstrings ; // Handle to access uSD strings, uncomment if required
    // var hFontx ; // Handle to access uSD fonts, uncomment if required and change n to font number
    // Uncomment the following if uSD images, fonts or strings used.
    /*
    // for Fat File System
    putstr("Mounting...\n");
    if (!(file_Mount()))
    while(!(file_Mount()))
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend
    endif
    // for (GCI) Flash File System
    media_Init() ; // or media_Init4(FLASH_ADDR_DEF_COMMAND) if flash > 16MB
    // gfx_TransparentColour(0x0020); // uncomment if transparency required, please understand why and when you need to use this
    // gfx_Transparency(ON); // uncomment if transparency required, as generally there is a performance hit when using it
    
    // for Fat File System
    // hFontn := file_LoadImageControl("SERIAL~1.dan", "SERIAL~1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
    // hstrings := file_Open("SERIAL~1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
    hndl := file_LoadImageControl("SERIAL~1.dat", "SERIAL~1.gci", 1);
    // for (GCI) Flash File System
    hndl := file_LoadImageControl(0, 0, 3); // fonts, strings and WAV files are all entries in here.
    */
    
    com_SetBaud(COM0, 960);
    var cmdbuf[13];
    repeat
    readCmd();
    pause(2000);
    
    forever
    endfunc
    However when I run the following Arduino Script, nothing is displayed on the Display:

    Code:
    /*
    char mystr[5] = "Hello";
    
    
    void setup() {
    // initialize serial communication at 9600 bits per second:
    Serial.begin(9600);
    
    pinMode(4, OUTPUT);
    digitalWrite(4,HIGH);
    
    
    }
    
    // the loop routine runs over and over again forever:
    void loop() {
    
    Serial.write(0x30);
    delay(1000); // delay in between reads for stability
    }
    What am I doing wrong?

    When I use the Arduino serial monitor the screen is reading the value though
    Last edited by BrunoSenzio; 16 February 2021, 12:45 PM.

  • #2
    Nevermind... I figured it out...

    Comment

    Working...
    X