Skip to content

Instantly share code, notes, and snippets.

View kkmonster's full-sized avatar
🏠
Working from home

Wasin Wongkum kkmonster

🏠
Working from home
View GitHub Profile
#include <Arduino.h>
#include "corgi85_blynk.h"
void CORGI85_BLINK::loop(void)
{
switch (mode)
{
case stop:
#define sgn(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
#define off 0
#define on 1
#include "Arduino.h"
#include <ESP32Encoder.h> //https://github.com/madhephaestus/ESP32Encoder
#include <math.h>
// max velocity 1000 mm /s
// max acc 10 m /s^2
#include "Arduino.h"
#include <ESP32Encoder.h> //https://github.com/madhephaestus/ESP32Encoder
#include <math.h>
hw_timer_t *timer = NULL;
hw_timer_t *timer1 = NULL;
portMUX_TYPE sync = portMUX_INITIALIZER_UNLOCKED;
void recv()
{
while (Serial3.available() > 0)
{
for (byte index = 0; index < MAXLENGTH - 1; index++)
{
receivedCommandStack[index] = receivedCommandStack[index + 1];
}
receivedCommandStack[MAXLENGTH - 1] = Serial3.read();
#include "Arduino.h"
#include <ESP32Encoder.h> // https://github.com/madhephaestus/ESP32Encoder
#include <math.h>
hw_timer_t *timer = NULL;
hw_timer_t *timer1 = NULL;
portMUX_TYPE sync = portMUX_INITIALIZER_UNLOCKED;
ESP32Encoder encoder;
const int encoderA_pin = 21;
// wasin wongkum demo inverted pendulum on nano32(ESP32)
#include <ESP32Encoder.h> // https://github.com/madhephaestus/ESP32Encoder
#include <math.h>
hw_timer_t *timer = NULL;
hw_timer_t *timer1 = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
ESP32Encoder encoder;
@kkmonster
kkmonster / finding_wn.ino
Created May 9, 2020 17:26
finding wm of pendulun by esp32
#include <ESP32Encoder.h>
hw_timer_t *timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
ESP32Encoder encoder;
const int encoderA_pin = 25;
const int encoderB_pin = 26;
const int encoder_CPR = 1600;
uint8_t got_cmd = 0;
for (int tmp = 0; tmp < sizeof(command_tmp) - 7; tmp++) {
if (command_tmp[tmp] == 0xff && command_tmp[tmp + 1] == 0xfe) {
uint16_t sumcheck = 0;
uint16_t sumget = (uint16_t) command_tmp[tmp + 6] << 8 | (uint16_t) command_tmp[tmp + 7];
for (int tmp_2 = 0; tmp_2 < 6; tmp_2++) {
float f 1.23;
int val1 = f;
int val2 = (f * 10) % 10;
int val3 = (f * 100) % 10;
char buffer[20];
sprintf(buffer, "val = %d.%d%d", val1, val2, val3);
#include "arduino.h"
#include <SPI.h>
#include <SD.h>
#include <stdio.h>
#include <string.h>
const int chipSelect = PA4;
typedef struct data_log_typedef
{