2017年4月30日星期日

Arduino sketch

Open Arduino IDE
Press compile, compiles for the microprocessor on the board you select
Uploads over USB/serial (built into the IDE)
Sketch=small c program abstracted a bit to be dead simple (setup() for init and update() loop called “every frame”)

C++(99/11 depending on compiler)




const int EchoPin = 6;
const int TrigPin = 7;
SR04 sr04 = SR04(EchoPin,TrigPin);
long dis;
void setup() {
  Serial.begin(9600);
}

void loop() {
  dis=sr04.Distance();
  Serial.println(dis);
  delay(250);

没有评论:

发表评论