Ja, som det kan ses af nedenstående, så skriver jeg nogle gange på Engelsk.
Teksten til højre for // er en kort beskrivelse af hvad hver linje gør.
/* * Analog In 0 + 1 + 2 converted to DEC, HEX, °C and mV. */ int analogValue0 = 0; // Variable for analog value on A0 int outputValue0 = 0; // Making mapping possible for A0 int analogValue1 = 0; // Variable for analog value on A1 int outputValue1 = 0; // Making mapping possible for A1 int analogValue2 = 0; // Variable for analog value on A2 int outputValue2 = 0; // Making mapping possible for A2 void setup() // Run once, when the sketch starts { Serial.begin(9600); // Setting communication up at 9600 bps on TX pin at Arduino Uno Serial.write(0xFE); // Special Command Extended Serial.write(0x01); // Clear Display delay(10); // Delay for clearing the Display Serial.write(0x7C); // Special Command Serial.write(150); // Backlight brightness level (128 = Off, 140 = 40%, 150 = 73%, 157 = Fully On) delay(10); // Delay for changing Backlight brightness } void loop() // Run over and over again { analogValue0 = analogRead(0); // Reading of the analog input pin A0 analogValue1 = analogRead(1); // Reading of the analog input pin A1 analogValue2 = analogRead(2); // Reading of the analog input pin A2 Serial.print("A0"); // Pretext for A0 Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x03); // Move to Row 1 Column 4 Serial.print(analogValue0, DEC); // Print in ASCII-encoded decimal Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x08); // Move to Row 1 Column 9 Serial.print("0x"); // Pretext for Hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x0A); // Move to Row 1 Column 11 Serial.print(analogValue0, HEX); // Print in ASCII-encoded hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x10); // Move to Row 1 Column 17 outputValue0 = map(analogValue0, 0, 1023, 0, 500); // 10mV pr. °C (5V = 500°C) Serial.print(outputValue0); // * * * Temp value * * * Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x12); // Move to Row 1 Column 19 Serial.write(0xDF); // Symbol ° Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x13); // Move to Row 1 Column 20 Serial.print("C"); // Temp Scale Centigrade Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x40); // Move to Row 2 Column 1 Serial.print("A1"); // Pretext for A1 Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x43); // Move to Row 2 Column 4 Serial.print(analogValue1, DEC); // Print in ASCII-encoded decimal Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x48); // Move to Row 2 Column 9 Serial.print("0x"); // Pretext for Hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x4A); // Move to Row 2 Column 11 Serial.print(analogValue1, HEX); // Print in ASCII-encoded hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x4E); // Move to Row 2 Column 15 outputValue1 = map(analogValue1, 0, 1023, 0, 5000); // Read out in mV Serial.print(outputValue1); // Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x52); // Move to Row 2 Column 18 Serial.print("mV"); // Unit Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x14); // Move to Row 3 Column 1 Serial.print("A2"); // Pretext for A2 Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x17); // Move to Row 3 Column 4 Serial.print(analogValue2, DEC); // Print in ASCII-encoded decimal Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x1C); // Move to Row 3 Column 9 Serial.print("0x"); // Pretext for Hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x1E); // Move to Row 3 Column 11 Serial.print(analogValue2, HEX); // Print in ASCII-encoded hex Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x22); // Move to Row 3 Column 15 outputValue2 = map(analogValue2, 0, 1023, 0, 5000); // Read out in mV Serial.print(outputValue2); // * * * Temp value * * * Serial.write(0xFE); // Special Command Extended Serial.write(0x80+0x26); // Move to Row 3 Column 18 Serial.print("mV"); // Unit delay(1000); // Time for Display read out Serial.write(0xFE); // Special Command Extended Serial.write(0x01); // Clear Display }
Den opmærksomme læser vil nok bemærke, at der for Arduino Uno pin A0 udlæses Dec, Hex og °C men der for pin A1 + 2 udlæses Dec, Hex og mV.