Hi guys, I’m a newbee and fumbling my way through programing and I’m having some success. What I can’t figure out how to do is convert the kilometers that is read out of the lightning sensor and printed on the display into miles. I know the equation to do that but I’m not sure how to take the value from the code below which appears to print AO as a kilometers. At this time it prints 1km or 22km and I realize that converting to miles will give me a sort of odd number like 0.62 or 13.67.
Can someone tell me how to convert that value into miles. The code is below or for more detailed information into the program that I am using see this link: https://www.sparkfun.com/news/2968
Thanks,
Curt
void lightningData()
{
delay(100);
Wire.begin();
oled.begin(); // Initialize the OLED
oled.clear(ALL); // Clear the display’s internal memory
oled.display(); // Display what’s in the buffer (splashscreen)
delay(1000); // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.
printTitle(“Storm!”, 0);
oled.clear(PAGE); // Clear the screen
oled.setFontType(0); // Set font to type 0
oled.setCursor(0, 0); // Set cursor to top-left
delay(50); // Wait 500ms before next example
oled.clear(PAGE); // Clear the display
oled.setCursor(0, 0); // Set cursor to top-left
oled.setFontType(0); // Smallest font
oled.print("Distance: ");
oled.setCursor(16, 12);// Print “A0”
oled.setFontType(2);
oled.print(distanceview);
oled.setCursor(0, 34);
oled.setFontType(0);
oled.print(“Km Away!”);
oled.display();
Wire.end();
}
void printTitle(String title, int font)
{
int middleX = oled.getLCDWidth() / 2;
int middleY = oled.getLCDHeight() / 2;
oled.clear(PAGE);
oled.setFontType(font);
// Try to set the cursor in the middle of the screen
oled.setCursor(middleX - (oled.getFontWidth() * (title.length() / 2)),
middleY - (oled.getFontHeight() / 2));
// Print the title:
oled.print(title);
oled.display();
delay(1500);
oled.clear(PAGE);
}