int ledPin = 9; // LED connected to digital pin 9 int analogPin = A0; // potentiometer connected to analog pin A0 int val = 0; // variable to store the read value
void setup() { pinMode(ledPin, OUTPUT); // sets the pin as output }
void loop() { val = analogRead(analogPin); // read the input pin analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255 }
/* SerialEvent occurs whenever a new data comes in the hardware serial RX. This routine is run between each time loop() runs, so using delay inside loop can delay response. Multiple bytes of data may be available. */ void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag so the main loop can // do something about it: if (inChar == '\n') { stringComplete = true; } } }
Key Features • Worldwide 2.4GHz ISM band operation • Up to 2Mbps on air data rate • Ultra low power operation • 11.3mA TX at 0dBm output power • 12.3mA RX at 2Mbps air data rate • 900nA in power down • 22µA in standby-I • On chip voltage regulator • 1.9 to 3.6V supply range • Enhanced ShockBurst™ • Automatic packet handling • Auto packet transaction handling • 6 data pipe MultiCeiver™ • Air compatible with nRF2401A, 02, E1 and E2 • Low cost BOM • ±60ppm 16MHz crystal • 5V tolerant inputs • Compact 20-pin 4x4mm QFN package