Willian-Zhang / the-end-of-world

Apache License 2.0
0 stars 0 forks source link

Sample Code for output in Ardiuno #1

Open Willian-Zhang opened 6 years ago

Willian-Zhang commented 6 years ago
void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
}

void loop() {
  long start = millis();
  // put your main code here, to run repeatedly:
  Serial.print(millis() - start);
  Serial.print("\t");
  Serial.print("2");
  Serial.print("\t");
  Serial.print("254");
  Serial.print("\n");
  delay(1);
}
Willian-Zhang commented 6 years ago

or

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  long start = millis();
  // put your main code here, to run repeatedly:
  Serial.print(millis() - start);
  Serial.print("\t");
  Serial.print("0");
  Serial.print("\t");
  Serial.print(map(sensorValue, 0, 1023, 254, 0));
  Serial.print("\n");
  delay(1);
}