Saeid Moghadam
Published © MIT

AnyScan209: Android Data Visualizer

• “AnyScan209 maps 10‑bit environmental and magnetic data with real‑time 2D/3D visualization and internal or Bluetooth sensor input. ”

BeginnerWork in progress1 hour8
AnyScan209: Android Data Visualizer

Things used in this project

Hardware components

Android device
Android device
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
ATmega328
Microchip ATmega328
×1
M5Stack ISP USBasp Programmer (Random Color)
M5Stack ISP USBasp Programmer (Random Color)
×1

Story

Read more

Custom parts and enclosures

anyscan209_D2rWSOdvR3.png

Schematics

AnyScan209

The schematic below shows a simple wiring example using an ATmega328 microcontroller. In this demonstration, a potentiometer is used to generate an adjustable analog input value, and by pressing the send button, the measured value is transmitted via Bluetooth. Keep in mind that you can use any microcontroller and any type of sensor you prefer. This schematic is only a basic example to illustrate the concept

Code

Sample send code for AnyScan209

C/C++
The following BASIC code demonstrates a simple example of sending a 10‑bit value.
You can implement the same functionality, or a more advanced version, in any
programming language. For instance, the Arduino equivalent would be:

------------------------------------
BASIC Example
------------------------------------

$regfile = "m328pdef.dat"
$crystal = 11059200

Config Adc = Single , Prescaler = Auto , Reference = Avcc
Enable Interrupts
$baud = 9600

Config Portc.0 = Input 'Send Button
Dim V As Word

Do
V = Getadc(1) 'adc 1

If Portc.0 = 1 Then
Print V
Wait 2
End If

Loop


------------------------------------
Arduino Example
------------------------------------

int sendButton = A0; // Send button (digital input)
int adcPin = A1; // ADC input
int value = 0;

void setup() {
pinMode(sendButton, INPUT);
Serial.begin(9600);
}

void loop() {
value = analogRead(adcPin); // 0–1023

if (digitalRead(sendButton) == HIGH) {
Serial.println(value);
delay(2000); // 2 seconds
}
}


------------------------------------
C (AVR-GCC) Example
------------------------------------

#include <avr/io.h>
#include <util/delay.h>

void adc_init(void) {
ADMUX = (1 << REFS0); // AVcc reference, ADC0 by default
ADCSRA = (1 << ADEN) | // Enable ADC
(1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Prescaler 128
}

uint16_t adc_read(uint8_t channel) {
ADMUX = (ADMUX & 0xF0) | (channel & 0x0F); // Select ADC channel
ADCSRA |= (1 << ADSC); // Start conversion
while (ADCSRA & (1 << ADSC)); // Wait
return ADC;
}

int main(void) {
uint16_t value;

DDRC &= ~(1 << PC0); // PC0 as input (Send Button)
adc_init();

// UART init (9600 baud @ 11.0592 MHz)
UBRR0H = 0;
UBRR0F = 71; // 9600 baud
UCSR0B = (1 << TXEN0);
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);

while (1) {
value = adc_read(1); // Read ADC1

if (PINC & (1 << PC0)) {
// Send value
char buffer[10];
itoa(value, buffer, 10);

for (char *p = buffer; *p; p++)
while (!(UCSR0A & (1 << UDRE0)));
UDR0 = *p;

// New line
while (!(UCSR0A & (1 << UDRE0)));
UDR0 = '\n';

_delay_ms(2000);
}
}
}
No preview (download only).

Credits

Saeid Moghadam
3 projects • 0 followers
Electrical & electronics engineer sharing simple beginner‑level projects. Still learning, still improving. Feedback helps me grow.

Comments