4 - Joystick controlled Pan & Tilt Servo
I intentionally used the same vPins as the physical GPIO just for coding consistency, you can use most any pins you want.
const Gpio = require('pigpio').Gpio;
// Joystick with Pan & Tilt Servos
const PAN_PORT = 22;
const TILT_PORT = 23;
const pan = new Gpio(PAN_PORT, {mode: Gpio.OUTPUT});
const tilt = new Gpio(TILT_PORT, {mode: Gpio.OUTPUT});
var JoyX = new blynk.VirtualPin(22); // Setup Joystick X on V22
var JoyY = new blynk.VirtualPin(23); // Setup Joystick Y on V23
JoyX.on('write', function(panValue) { // Watches for Joystick X
pan.servoWrite(panValue); // Set Servo to value
});
JoyY.on('write', function(tiltValue) { // Watches for Joystick y
tilt.servoWrite(tiltValue); // Set Servo to value
});