Skip to content

Instantly share code, notes, and snippets.

@smching
smching / _8_LEDs_light_up_in_sequence.ino
Last active February 28, 2016 09:32
8 LEDs light up in sequence
int gpioCount=8;
int led_pin[9]={16,14,12,13,2,5,4,1};
void setup() {
for (byte i=0; i<gpioCount; i++) {
pinMode(led_pin[i], OUTPUT);
}
}
void loop() {
@smching
smching / Wireless_Router_Remote_Control_Car.ino
Created February 28, 2016 09:36
Wireless Router Remote Control Car
http://ediy.com.my/projects/item/99-wireless-router-remote-control-car
////////// blink LED variables
#define BLINK_LED_PIN 13 //the number of the LED pin
int ledState = LOW; //ledState used to set the LED
long previousMillis = 0; //will store last time LED was updated
long interval = 500; //interval at which to blink (milliseconds)
////////// motor variables
#define MOTOR_ENABLE_PWM_PIN 6 // H-bridge enable (pin 1 &amp; pin 9)
@smching
smching / car
Created February 28, 2016 09:52
Wireless Router Remote Control Car
#!/bin/sh
cmd=$QUERY_STRING
echo $cmd+"\r" > /dev/ttyUSB0
@smching
smching / car.lua
Last active March 5, 2016 05:18
Wireless Router Remote Control Car
#!/usr/bin/lua
port= "/dev/ttyUSB0"
serialout= io.open(port,"w") --open serial port and prepare to write data
str= os.getenv("QUERY_STRING").."\r" -- get message from URL and terminate with carriage return(\r), eg. @2\r
serialout:write(str)
@smching
smching / Controlling_DC_Motors_with_an_Arduino.ino
Created February 28, 2016 10:17
L298N Motor Driver Controller Board
#define FORWARD 8
#define BACKWARD 2
#define STOP 5
int Motor[2][2] = //two dimensional array
{
{4 , 5}, //input pin to control Motor1--> Motor[0][0]=4, Motor[0][1]=5
{6 , 7}, //input pin to control Motor2--> Motor[1][0]=6, Motor[1][1]=7
};
@smching
smching / Controlling_Motors_speed_with_an_Arduino.ino
Created February 28, 2016 10:20
L298N Motor Driver Controller Board
#define FORWARD 8
#define BACKWARD 2
#define STOP 5
#define PWM_PIN_1 9 //speed control pin for motor1
#define PWM_PIN_2 10 ///speed control pin for motor2
int Motor[2][2] = //two dimensional array
{
{4 , 5}, //input pin to control Motor1--> Motor[0][0]=4, Motor[0][1]=5
{6 , 7}, //input pin to control Motor2--> Motor[1][0]=6, Motor[1][1]=7
@smching
smching / Controlling_Bipolar_Stepper_Motors_with_an_Arduino.ino
Created February 28, 2016 10:24
L298N Motor Driver Controller Board
#define OUT1 4 //Digital 4 connect to L298 IN1
#define OUT2 5 //Digital 5 connect to L298 IN2
#define OUT3 6 //Digital 6 connect to L298 IN3
#define OUT4 7 //Digital 7 connect to L298 IN4
int motor_speed = 20; //delay 20 milliseconds (smaller is faster)
void setup() {
pinMode(OUT1, OUTPUT);
pinMode(OUT2, OUTPUT);
pinMode(OUT3, OUTPUT);
@smching
smching / shiftOut_example.lua
Created February 28, 2016 10:35
Lua_ShiftOut: A 74HC595 Shift Register Library for Lua
#!/usr/bin/lua
require "gpio"
require "shiftOut"
require "bit"
print("===== LSBFIRST =====")
for i= 0, Number_of_bit do
value=nixio.bit.lshift(1,i)
print("update_ShiftRegister("..value..",LSBFIRST)")
update_ShiftRegister(value,LSBFIRST)
@smching
smching / control
Created February 28, 2016 10:38
Lua_ShiftOut: A 74HC595 Shift Register Library for Lua
#!/usr/bin/lua
require "gpio" --import gpio library
require "shiftOut" --import shiftOut library
str= os.getenv("QUERY_STRING") --gets the value from URL
parameter= string.sub(str,1) --from character one until the end
value=tonumber(parameter) --convert string to integer
update_ShiftRegister(value,LSBFIRST)
@smching
smching / RGB_Matrix_LED_tester.ino
Created March 1, 2016 14:26
Arduino based RGB Matrix LED tester
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8 // MUST be on PORTB!
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
// Last parameter = 'false' disable double-buffering