Skip to content

Liyab Basic Microcontroller Library #12043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/testdata/libraries/LiyabBasic/examples/Liyab_Knob.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Liyab Basic Microcontroller - Knob Calibration */

#include <LiyabBasic.h>

#define knob A2

void setup() {
Liyab_Init();
OK();
}

void loop() {
int value = analogRead(knob);
Serial.println(value);
}
30 changes: 30 additions & 0 deletions app/testdata/libraries/LiyabBasic/examples/Liyab_Motors.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Liyab Basic Microcontroller - Motor Control */

#include <LiyabBasic.h>

void setup() {
Liyab_Init();
OK();
}

void loop() {
motor(1, 50);
motor(2, 50);
delay(1000);

motor(1, -50);
motor(2, -50);
delay(1000);

motor(1, 50);
motor(2, -50);
delay(1000);

motor(1, -50);
motor(2, 50);
delay(1000);

motor(1, 0);
motor(2, 0);
delay(1000);
}
9 changes: 9 additions & 0 deletions app/testdata/libraries/LiyabBasic/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=LiyabBasic
version=1.0.0
author=John David Golenia
maintainer=John David Golenia <goleniajohndavid11@gmail.com>
sentence=Library for Liyab Basic Microcontroller
paragraph=This library facilitates the use of the Liyab Basic Microcontroller produced by GearTech Robots Trading, making robotics more user-friendly for beginners.
category=Uncategorized
url=https://github.com/TGC-GearTech/LiyabBasic
architectures=*
87 changes: 87 additions & 0 deletions app/testdata/libraries/LiyabBasic/src/LiyabBasic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include "Arduino.h"
#include "LiyabBasic.h"

// Initialization function
void Liyab_Init() {
Serial.begin(9600);

pinMode(2, OUTPUT); // Buzzer pin

pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);

// Play a sound on the buzzer
tone(2, 1250, 350);
tone(2, 1250, 350);
}

// Function to wait until a button is pressed
void OK() {
pinMode(13, INPUT_PULLUP);
while (digitalRead(13) == 0) {
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
}
}

// Motor control function
void motor(uint8_t pin, int speed) {
if (pin == 1) {
if (speed > 0) {
int spd = map(speed, 0, 100, 0, 255);
analogWrite(9, spd);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
}

if (speed < 0) {
int spd = map(speed, 0, -100, 0, 255);
analogWrite(9, spd);
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
}

if (speed == 0) {
analogWrite(9, 0);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
}
}

if (pin == 2) { // Motor 2 control
if (speed > 0) {
int spd = map(speed, 0, 100, 0, 255);
analogWrite(10, spd);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
}

if (speed < 0) {
int spd = map(speed, 0, -100, 0, 255);
analogWrite(10, spd);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
}

if (speed == 0) {
analogWrite(10, 0);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
}
}
}

// Stop both motors
void motor_stop() {
analogWrite(9, 0);
analogWrite(10, 0);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
}
15 changes: 15 additions & 0 deletions app/testdata/libraries/LiyabBasic/src/LiyabBasic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Liyab Basic Microcontroller Library */
/* Written by GearTech Robots Trading */

#ifndef LiyabBasic_h
#define LiyabBasic_h

#include "Arduino.h"

// Function prototypes
void Liyab_Init();
void OK();
void motor(uint8_t pin, int speed);
void motor_stop();

#endif