You may also want to test the other GPIOs of your DIY Moteino. Here are some simple analog pin tests. We can use a potentiometer as input to A6 and A7, and the onboard LED (on digital pin 9) to be PWM-ed as output depending on the pot position. Here is the test sketch for testing A6 input:
const int analogInPin = A6; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // 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);
pinMode(0, OUTPUT);
pinMode(A4, OUTPUT);
digitalWrite(0, HIGH);
digitalWrite(A4, LOW);
}
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);
// wait 2 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(2);
}
And here’s a test sketch for testing A7 input:
const int analogInPin = A7; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // 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);
pinMode(1, OUTPUT);
pinMode(A5, OUTPUT);
digitalWrite(1, HIGH);
digitalWrite(A5, LOW);
}
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);
// wait 2 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(2);
}
For both sketches you will need a potentiometer (any will work) as seen in pictures above. Here’s the LED output at low duty cycle:
Here is the same sketch with the pot turned all the way, the LED is now very bright:
And finally here’s a sketch for checking all other GPIO. This sketch outputs a ~100Hz square wave signal on every output except A6,A7:
void setup() {
for(byte i=0;i<19;i++) {
pinMode(i, OUTPUT);
}
}
void loop() {
for(byte i=0;i<19;i++) {
digitalWrite(i, !digitalRead(i));
}
delay(5);
}
Congratulations, you have assembled and tested your own DIY Moteino, you are on the way to becoming an SMD soldering master!