![]() ![]() Pin state is low or 0, switch is open (pull-down resistor)ĭigitalWrite(LED_BUILTIN, LOW) // Switch L LED offģ.3.1.2 Pins as Inputs, Pull-up Resistor Pin state is high or 1, switch is closed (pull-down resistor)ĭigitalWrite(LED_BUILTIN, HIGH) // Switch L LED on Read Arduino MEGA 2560 pin 2 state with pull-down resistor. Serial.print(voltage) // Display voltageĢ.7.5.4 Analog In Pins Used as Digital I/O, Īrduino MEGA 2560 analog pin A0 used as a digital output pin.ģ.3.1.2 Pins as Inputs, Pull-down Resistor Int sensorValue = analogRead(A0) // Read ADC valueįloat voltage = (5.0 / 1024.0) * (float)sensorValue // Calculate voltage PinMode(MY_LED, OUTPUT) // Configure digital pin as an output pinĭigitalWrite(MY_LED, HIGH) // Set pin voltage to 5V on a MEGA 2560ĭigitalWrite(MY_LED, LOW) // Set pin voltage to 0V or GNDĪrduino MEGA 2560 PWM on pin 3 with 50% duty cycle.Ģ.7.5.3 Calculating Analog In Voltage, Ĭalculating analog input voltage on Arduino MEGA 2560 A0 pin. PinMode(12, OUTPUT) // Configure digital pin 12 as an output pinĭigitalWrite(12, HIGH) // Set pin 12 voltage to 5V on a MEGA 2560ĭigitalWrite(12, LOW) // Set pin 12 voltage to 0V or GNDĭefining a pin with a user friendly name. PinMode(LED_BUILTIN, OUTPUT) // Configure L LED pin as outputĭigitalWrite(LED_BUILTIN, HIGH) // Switch L LED ONĭigitalWrite(LED_BUILTIN, LOW) // Switch L LED OFFĭelay(200) // Leave L LED OFF for periodĪrduino MEGA 2560 pin 12 configured as an output and driven high and low. Sketches are displayed below under the section number that they occur in in the book, with the page number that they can be found on. Select the desired sketch and copy the code, then paste it to the Arduino IDE. ![]() ![]() Arduino Sketches from the Ultimate Arduino MEGA 2560 Hardware Manual can be found below. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |