• 追加された行はこの色です。
  • 削除された行はこの色です。
* Bluetooth+SBDBT [#rfe9bad1]

|  |*↓挿入口↓|<|<||
|*5|PGEC1 ||STATUS|*10|
|*4|PGED1 ||CTS   |*9 |
|*3|GND   ||RX    |*8 |
|*2|VDD=3V||TX    |*7 |
|*1|RESET ||RTS   |*6 |

###
Arduino arduino;
SBDBT   sbdbt;

sbdbt.gnd = Arduino.gnd;
sbdbt.vdd = Arduino.3V ;
sbdbt.rx  = Arduino.tx ;
sbdbt.tx  = Arduino.rx ;
sbdbt.cts = sbdbt.rts  ;
###


###
void setup() {
  Serial.begin(9600);
}

int c = 0;
void loop() {
  Serial.println(c++);
  delay(500);
}
###

* Python + Pyserial [#ia698899]
###
#need pyserial:
# $> pip install pyserial
* Python x Arduino [#mfd0c1d4]
*** Python + Pyserial [#q5d690bb]

import serial

seri = serial.Serial("COM11", 9600, timeout=1000)
print("Open [{}]".format(seri))

try:
### python
  #need pyserial:
  # $> pip install pyserial
  
  import serial
  
  seri = serial.Serial("COM11", 9600, timeout=1000)
  print("Open [{}]".format(seri))
  
  try:
    while True:
        line = seri.readline()
        value = int(line)
        print(value)
        if value != 1:
            print("Emergency Stop!")
            break      
except:
      line = seri.readline()
      value = int(line)
      print(value)
      if value != 1:
        print("Emergency Stop!")
        break      
  except:
    print("Error Stop!!")
finally:
  finally:
    seri.close()
###

*** Arduino + Serial [#b2b91c98]

### cpp
  int iSwitch = 2;
  int oLedOn  =  3;
  int oLedOff = 10;
  
  void setup(){
    pinMode(iSwitch, INPUT);
    pinMode(oLedOn , OUTPUT);
    pinMode(oLedOff, OUTPUT);
    Serial.begin(9600);
    Serial.write("Heart Beat Start");
  }
  
  void loop(){
    int vSwitch = digitalRead(iSwitch);
    digitalWrite(oLedOn ,  LOW);
    Serial.print(vSwitch);
    Serial.println("");
    digitalWrite(oLedOff, !vSwitch);
    delay(10);
    digitalWrite(oLedOn ,  vSwitch);
    delay(90);
  }
###

* [#r1a1cf01]

    技術 一覧 検索 最新 バックアップ リンク元   ヘルプ   最終更新のRSS