Commit b0eaba7b authored by Nelso Jost's avatar Nelso Jost

NEW: first scratch code for testing the Piezzo sensor

parents
.pioenvs
all: build serial
build:
platformio run -e uno -t upload
serial:
picocom -b 9600 /dev/ttyACM0
install-picocom:
sudo apt-get install picocom
install-platformio:
sudo python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
clean:
rm -rf .pioenvs/
This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.
The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".
For example, see how can be organized `Foo` and `Bar` libraries:
|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c
Then in `src/main.c` you should use:
#include <Foo.h>
#include <Bar.h>
// rest H/C/CPP code
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.
See additional options for PlatformIO Library Dependency Finder `lib_*`:
http://docs.platformio.org/en/latest/projectconf.html#lib-install
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload
[env:uno]
platform = atmelavr
framework = arduino
board = uno
#define YELLOW_LED_PIN 8
#define RED_LED_PIN 13
#define RED_THRESHOLD 50
#define YELLOW_MIN_THRESHOLD 6
#define YELLOW_MAX_THRESHOLD 10
int pv; // piezzo value
unsigned long previousMillis = 0;
int led_state=LOW;
void setup()
{
Serial.begin(9600);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(YELLOW_LED_PIN, OUTPUT);
}
void loop()
{
pv = analogRead(0);
if (pv >= YELLOW_MIN_THRESHOLD && pv <= YELLOW_MAX_THRESHOLD)
{
digitalWrite(YELLOW_LED_PIN, HIGH);
Serial.println(pv);
}
else
{
digitalWrite(YELLOW_LED_PIN, LOW);
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 500)
{
previousMillis = currentMillis;
led_state = (led_state == LOW) ? HIGH : LOW;
digitalWrite(RED_LED_PIN, led_state);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment