Please be aware of all shipping deadlines before placing your order - we cannot guarantee orders will arrive before Christmas!

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);
}

 

Check out all the Circuit Playground Episodes! Our new kid’s show and subscribe!

Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground”Adafruit’s Apps!



No Comments

No comments yet.

Sorry, the comment form is closed at this time.