Add potiNano Code
This commit is contained in:
parent
e2bf85c91e
commit
69f1cba2f8
5
terminal/puzzle_colorFade/potiNano/.gitignore
vendored
Normal file
5
terminal/puzzle_colorFade/potiNano/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
||||||
14
terminal/puzzle_colorFade/potiNano/platformio.ini
Normal file
14
terminal/puzzle_colorFade/potiNano/platformio.ini
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:nanoatmega328new]
|
||||||
|
platform = atmelavr
|
||||||
|
board = nanoatmega328new
|
||||||
|
framework = arduino
|
||||||
28
terminal/puzzle_colorFade/potiNano/src/main.cpp
Normal file
28
terminal/puzzle_colorFade/potiNano/src/main.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#define I2C_SLAVE_ADDRESS 0x08
|
||||||
|
|
||||||
|
uint16_t values[6] = {0};
|
||||||
|
|
||||||
|
void onI2CRequest() {
|
||||||
|
Wire.write((uint8_t*)values, sizeof(values));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Wire.begin(I2C_SLAVE_ADDRESS);
|
||||||
|
Wire.onRequest(onI2CRequest);
|
||||||
|
|
||||||
|
analogReference(DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
values[0] = analogRead(A0);
|
||||||
|
values[1] = analogRead(A1);
|
||||||
|
values[2] = analogRead(A2);
|
||||||
|
|
||||||
|
values[3] = analogRead(A3);
|
||||||
|
values[4] = analogRead(A6);
|
||||||
|
values[5] = analogRead(A7);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user