Home > Uncategorized > Example programs for ArduinoPixed

Example programs for ArduinoPixed

October 8th, 2018

Example : LED Blinking

This example will blink and LED for 1 sec and off for 0.2 second on the Arduinopixed. Note that the LED is connected on Pin 6 in place of 13 in Arduino or Arduino Nano.


void setup() {
pinMode(6, OUTPUT);
}

void loop() {
digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
}

Example : LED ON off on Push button

The example will turn on or off the LED on Arduoinopixed depending upon if the the Push Button is pressed or not. The push button is connected on Pin 7 and is normally high. When the Push Button is pressed, it turns low.

const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 6; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

Example : A/D Converter that throws Sensed value at Serial Port every 500 ms


const int analogInPin = A7; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 6; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the Serial Monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

//500 ms wait
delay(500);
}

Uncategorized

  1. No comments yet.
  1. No trackbacks yet.