#include <SPI.h>
int led = 2;
char led_recv_status = 0;
void setup() {
Serial.begin(9600);
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
if (Serial.available() > 0)
{
led_recv_status = Serial.read();
if (led_recv_status == 'o')
{
digitalWrite(led, HIGH); //led on
Serial.println("led on");
}
else if (led_recv_status == 'f')
{
digitalWrite(led, LOW); //led off
Serial.println("led off");
}
}
}
本文链接:https://blog.nnwk.net/article/119
有问题请留言。版权所有,转载请在显眼位置处保留文章出处,并留下原文连接
Leave your question and I'll get back to you as soon as I see it. All rights reserved. Please keep the source and links
友情链接:
子卿全栈
全部评论