sohotcall

FPM10A GenImg Arduino NodeMCU ESP8266

May 3rd, 2019
137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "SoftwareSerial.h"
  2.  
  3. // 14, 12 adalah angka GPIO, bukan angka label
  4. // NodeMCU, label (GPIO): D0(16), D5(14), D6(12), D7(13), D8(15), D4(2), D3(0), D2(4), D1(5)
  5. SoftwareSerial fpm( 14, 12, false, 256 ); // (micro.rx/fpm.tx, micro.tx/fpm.rx, false, 256)
  6.  
  7. void setup() {
  8.   Serial.begin( 115200 );
  9.   fpm.begin( 57600 );
  10.   Serial.println("Ready");
  11. }
  12.  
  13. void loop() {
  14.   while ( Serial.available() > 0 ){
  15.     char c = Serial.read();
  16.     if ( c == 'G' ){
  17.       Serial.println("GenImg");
  18.       fpm.write( (uint8_t) 0xEF );
  19.       fpm.write( (uint8_t) 0x01 );
  20.       fpm.write( (uint8_t) 0xFF );
  21.       fpm.write( (uint8_t) 0xFF );
  22.       fpm.write( (uint8_t) 0xFF );
  23.       fpm.write( (uint8_t) 0xFF );
  24.       fpm.write( (uint8_t) 0x01 );
  25.       fpm.write( (uint8_t) 0x00 );
  26.       fpm.write( (uint8_t) 0x03 );
  27.       fpm.write( (uint8_t) 0x01 );
  28.       fpm.write( (uint8_t) 0x00 );
  29.       fpm.write( (uint8_t) 0x05 );
  30.     }
  31.   }
  32.   while ( fpm.available() > 0 ){
  33.     Serial.print("FPM: ");
  34.     while ( fpm.available() > 0 ){
  35.       Serial.print( fpm.read(), HEX );
  36.       Serial.print( ' ' );
  37.     }
  38.     Serial.println();
  39.   }
  40. }
RAW Paste Data