“激光发射”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
(创建页面,内容为“=== Arduino示例 === <pre style="color:blue"> int buttonPin =2; int laserPin=3; int val; void setup() { // put your setup code here, to run once: Serial.…”)
(没有差异)

2018年1月8日 (一) 08:24的版本

Arduino示例

int buttonPin =2;     
int laserPin=3; 
int val;
void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   pinMode(buttonPin,INPUT);
   pinMode(laserPin,OUTPUT);
}

void loop() {
   val=digitalRead(buttonPin);
   Serial.print(val);
   if(val==HIGH)
   {
     digitalWrite(laserPin,HIGH);
   }
   else
   {
     digitalWrite(laserPin,LOW);
   }
}