//这是我的arduino代码
const int BUTTON_SWITCH = 8;
const int BUTTON_ALARM = 9;
const int POT = A0;
const int RED_LED = 4;
const int BUZZER =3;
int index = 0;
double value;
int state = 0;
unsigned long time_now = 0;
int period =1000;
void setup() {
Serial.begin(9600);
pinMode(BUTTON_SWITCH, INPUT_PULLUP);
pinMode(BUTTON_ALARM, INPUT_PULLUP);
pinMode(RED_LED,OUTPUT);
}
void loop() {
if(digitalRead(BUTTON_SWITCH)==LOW && state == 0){
digitalWrite(RED_LED,HIGH);
digitalWrite(BUZZER,HIGH);
}
float reset;
reset = Serial.parseFloat();
if(reset == 0){
digitalWrite(RED_LED,HIGH);
digitalWrite(BUZZER,LOW);
}
// and here is the code from visual studio
private void Button1_Click(object sender, EventArgs e)
{
serialPort1.WriteLine("0");
}
// Im写一个程序,我要做的一件事就是用按钮点亮arduino上的第一个LED,然后用c#visual studio按钮停止。问题是为什么当我...
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
String incomingByte=Serial.readString();
if(incomingByte=="0")
{
digitalWrite(RED_LED,HIGH);
digitalWrite(BUZZER,LOW);
}
}
}