add joystick, add BB-L Bridge
This commit is contained in:
parent
223ea26eb4
commit
578dbaa431
|
@ -23,7 +23,7 @@ long_line_behaviour=1
|
||||||
long_line_column=72
|
long_line_column=72
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
current_page=-1
|
current_page=0
|
||||||
|
|
||||||
[VTE]
|
[VTE]
|
||||||
last_dir=/home/harald
|
last_dir=/home/harald
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
#define PLATFORM_HAS_BATTERY 1
|
#define PLATFORM_HAS_BATTERY 1
|
||||||
|
|
||||||
|
|
||||||
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
#define LOOP_INTERVAL (CLOCK_SECOND/10)
|
||||||
|
|
||||||
/* Save energy */
|
/* Save energy */
|
||||||
//#define RDC_CONF_PT_YIELD_OFF
|
//#define RDC_CONF_PT_YIELD_OFF
|
||||||
|
|
||||||
/* For Debug: Dont allow MCU sleeping between channel checks */
|
/* For Debug: Dont allow MCU sleeping between channel checks */
|
||||||
//#undef RDC_CONF_MCU_SLEEP
|
#undef RDC_CONF_MCU_SLEEP
|
||||||
//#define RDC_CONF_MCU_SLEEP 0
|
#define RDC_CONF_MCU_SLEEP 0
|
||||||
|
|
||||||
/* Disabling RDC for demo purposes. Core updates often require more memory. */
|
/* Disabling RDC for demo purposes. Core updates often require more memory. */
|
||||||
/* For projects, optimize memory and enable RDC again. */
|
/* For projects, optimize memory and enable RDC again. */
|
||||||
|
|
|
@ -19,14 +19,45 @@ extern resource_t res_led, res_battery, res_cputemp;
|
||||||
|
|
||||||
uint8_t led_pin=4;
|
uint8_t led_pin=4;
|
||||||
uint8_t led_status;
|
uint8_t led_status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merkurboard and BB-L298 connected to it.
|
||||||
|
// |---------------------------------------------------------------------------|
|
||||||
|
// | The connections were as follows: |
|
||||||
|
// |--------------------------------|------------------------------------------|
|
||||||
|
// |Connector at Merkurboard Grove 4| Connector at BB-L298 |
|
||||||
|
// |--------------------------------|------------------------------------------|
|
||||||
|
// | Power<3>, 3V | CTRL<1>, +5V |
|
||||||
|
// | Power<4>, GND | CTRL<8>, GND |
|
||||||
|
// | Power<5>, GND | PWR<2>, GND |
|
||||||
|
// | Power<6>, VIN(@12VDC) | PWR<1>, VIN |
|
||||||
|
// | DIGITAL<3>, D3 | CTRL<5>, Enable_B |
|
||||||
|
// | DIGITAL<17>, D17 | CTRL<6>, IN3 |
|
||||||
|
// | DIGITAL<18>, D18 | CTRL<7>, IN4 |
|
||||||
|
// |--------------------------------|------------------------------------------|
|
||||||
|
|
||||||
|
#define BB_Enable_B 3
|
||||||
|
#define BB_IN3 17
|
||||||
|
#define BB_IN4 18
|
||||||
|
|
||||||
|
#define IN3_L digitalWrite(BB_IN3, LOW);
|
||||||
|
#define IN3_H digitalWrite(BB_IN3, HIGH);
|
||||||
|
#define IN4_L digitalWrite(BB_IN4, LOW);
|
||||||
|
#define IN4_H digitalWrite(BB_IN4, HIGH);
|
||||||
|
|
||||||
#include <Grove_LED_Bar.h>
|
#include <Grove_LED_Bar.h>
|
||||||
|
|
||||||
Grove_LED_Bar bar(9, 8, 1); // Clock pin, Data pin, Orientation
|
Grove_LED_Bar bar(9, 8, 1); // Clock pin, Data pin, Orientation
|
||||||
|
|
||||||
void setup (void)
|
void setup (void)
|
||||||
{
|
{
|
||||||
|
// BB-L298
|
||||||
|
pinMode(BB_IN3, OUTPUT);
|
||||||
|
pinMode(BB_IN4, OUTPUT);
|
||||||
|
IN3_L;
|
||||||
|
IN4_L;
|
||||||
|
analogWrite(BB_Enable_B, 0);
|
||||||
// switch off the led
|
// switch off the led
|
||||||
pinMode(led_pin, OUTPUT);
|
pinMode(led_pin, OUTPUT);
|
||||||
digitalWrite(led_pin, HIGH);
|
digitalWrite(led_pin, HIGH);
|
||||||
|
@ -47,12 +78,17 @@ void setup (void)
|
||||||
|
|
||||||
void loop (void)
|
void loop (void)
|
||||||
{
|
{
|
||||||
static int i = 0;
|
static int vbar = 0;
|
||||||
|
int sensorValue1 = analogRead(A4);
|
||||||
|
int sensorValue2 = analogRead(A5);
|
||||||
|
|
||||||
|
vbar = sensorValue2/100;
|
||||||
// Walk through the levels
|
// Walk through the levels
|
||||||
bar.setLevel(i++);
|
bar.setLevel(10-vbar);
|
||||||
if (i >= 10){
|
if (vbar >= 10){
|
||||||
i=0;
|
vbar=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("x: %d , y: %d \n",sensorValue1,sensorValue2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue