接收端:
#include <stdlib.h>
int EN = 6 ;
int IN1 =9 ;
byte sensorValue;
int m;
int n;
void setup()
{
Serial.begin(9600);
pinMode(IN1,OUTPUT);
}
void loop()
{
if (Serial.available() > 0) {
sensorValue = Serial.read ();
m = int(sensorValue);
n =m/4;
analogWrite(IN1, n);
Serial.println(n);
delay(500);