User Tools

Site Tools


lpc1343

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lpc1343 [2010/09/08 19:47]
ladyada
lpc1343 [2016/01/28 18:05] (current)
Line 85: Line 85:
  
 You'll see a message every second when the LED changes state You'll see a message every second when the LED changes state
 +
 +====== Adding analog ======
 +
 +You can read from the ADC converter (it can do up to 200ksps) quite easily!
 +
 +<​code>​
 +#include "​sysinit.h"​
 +#include "​core/​adc/​adc.h"​
 +
 +int main (void)
 +{
 +  // Configure cpu and mandatory peripherals
 +  systemInit();​
 +
 +  // initialize the internal ADC
 +  adcInit();
 +
 +  while (1)
 +  {
 +    #ifdef CFG_INTERFACE
 +      // Handle any incoming command line input
 +      cmdPoll();
 +    #else
 +      // Toggle LED @ 1 Hz
 +      systickDelay(1000);​
 +      if (gpioGetValue(CFG_LED_PORT,​ CFG_LED_PIN))  ​
 +        gpioSetValue (CFG_LED_PORT,​ CFG_LED_PIN,​ CFG_LED_ON);​
 +      else 
 +        gpioSetValue (CFG_LED_PORT,​ CFG_LED_PIN,​ CFG_LED_OFF);​
 +
 + // Say Hello to my little friend!
 + printf("​Analog 0: %d\n\r",​ adcRead(0));​
 +
 +    #endif
 +  }
 +}
 +</​code>​
 +
 +{{:​lpcanalogtest.jpg?​500|}}
 +
 +{{:​analog0-pot.gif|}}
/home/ladyada/public_html/wiki/data/attic/lpc1343.1283975259.txt.gz · Last modified: 2016/01/28 18:05 (external edit)