May 20, 2009 AT 5:21 pm

Arduino sketch HTML formatter

Pt 1954
Want pretty Arduino sketches to include in your blog, just like us? Well, here is a little javascript fun! Use the Tools > Copy for Forum menu selection in the Arduino IDE to put the code into your computer clipboard. Then paste it in the form here – you’ll get nice HTML just posting code on the web, it will look like this…

 
 
int fsrAnalogPin = 0; // FSR is connected to analog 0
int LEDpin = 11;      // connect Red LED to pin 11 (PWM pin)
int fsrReading;      // the analog reading from the FSR resistor divider

void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
  pinMode(LEDpin, OUTPUT);
}

void loop(void) {
  fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);

  // LED gets brighter the harder you press
  analogWrite(LEDpin, fsrReading);
  
  delay(100);
}

 
Related

No Comments

No comments yet.

Sorry, the comment form is closed at this time.