Programming in Arduino

This is an example for a blink program in Arduino That blinks a Built-in LED.

// the setup function runs once when you press reset or power the board
//// funkcja konfiguracji uruchamia się raz po naciśnięciu resetu lub zasileniu płyty
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever. funkcja pętli działa w kółko na zawsze
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level). włącz diodę LED
  delay(1000);                       // wait for a second. Czekamy 1 Sekunda
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW. wyłącz diodę LED
  delay(1000);                       // wait for a second. Czekamy 1 Sekunda
}

A New Language , A New Beginning.

Yesterday 14 April 2020…I Started Learning A New Programming Language GO. GO also called GoLang is a good competitor to Python .. It is said that Languages like C++ and JAVA are really fast and efficient BUT hard to maintain, on the other hand Python is Easy to maintain but really slow and inefficent. But GoLang is Both, Easy to maintain and Efficient…Here is my First code <Hello World/>

package main

import "fmt"

func main() {
	fmt.Printf("hello, world\n")
}

My PB in 3X3X3 Cube

From a Long Time I have been Practicing Intermidate F2L And I got Better at PLL and First Cross…In the past Years I Struggled To Solve the cube in 1 minute and 30 Seconds.. But from the past month I have been Practicing CFOP method And it makes a LOT of difference. First I managed to get 1 minute, Then 54 Seconds, then 48 seconds, then 46.4 Seconds ( Those are my PBs – Personal Best ) My current PB is 39 Seconds..

This is a ScreenShot of an App That I made which can communicate with Arduino…More On That Later because it is Yet to be Published on Play Store….

12 DOF Quadrapod Spider

On Last Weekend I Made A Quadrapod Spider(11 to 12 of April).. I didn’t have enough parts for it so I took Apart my 17 Dof Humanoid Robot (The One On The Right Most) AND my 8 Dof Humanoid Robot (The Black On In The Middle).

MY ROBOT FAMILY
MY QUADRAPOD ROBOT

It was made using a 24-Channel Servo Shield and an Arduino Uno. All the action Groups is Stored in the Servo Shield And I trigger them through Arduino which get input from a PlayStation 2 Controller…This is the code for Arduino…

#include <PS2X_lib.h>   
PS2X ps2x; 
#include <LobotServoController.h>

#define rxPin 9
#define txPin 8
int error = 0; 
byte type = 0;
byte vibrate = 0;
SoftwareSerial mySerial(rxPin, txPin);
LobotServoController myse(mySerial); 
void setup(){
  mySerial.begin(9600); 
Serial.begin(9600);
error = ps2x.config_gamepad(13,11,10,12, true, true);   //GamePad(clock, command, attention, data, Pressures?, Rumble?) 
if(error == 0){
  
}
 else if(error == 1)
  Serial.print("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
 else if(error == 2)
  Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips");
 else if(error == 3)
  Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
  type = ps2x.readType(); 
    switch(type) {
      case 0:
       Serial.println("Unknown Controller type");
      break;
      case 1:
       Serial.println("DualShock Controller Found");
      break;
      case 2:
        Serial.println("GuitarHero Controller Found");
      break;
    }
}//from keystrokes import PressKey, ReleaseKey
void loop(){

if(error == 1) {
 return; 
}
else { //DualShock Controller
   ps2x.read_gamepad(false, vibrate);          //read controller and set large motor to spin at 'vibrate' speed
   if(ps2x.ButtonPressed(PSB_START))                   //will be TRUE as long as button is pressed
        myse.runActionGroup(0,1); 
   
    if(ps2x.Button(PSB_PAD_RIGHT)){

      myse.runActionGroup(4,0); 
     }
     if(ps2x.Button(PSB_PAD_UP)){
      myse.runActionGroup(1,0); 
     }
     if(ps2x.Button(PSB_PAD_LEFT)){
     myse.runActionGroup(3,0); 
     }
     if(ps2x.Button(PSB_PAD_DOWN)){
      myse.runActionGroup(2,0); 
     }  
     

           

}
delay(50);
} 

Thanks For Reading Subscribe For More…

HOW TO SOLVE THE CUBE

Step 1: How to solve the white edge pieces in the first layer

BAD WHITE CROSS
GOOD WHITE CROSS

The easiest step is solving the first layer edges of the Rubik’s Cube. Choose one color you want to start with. In this beginner’s tutorial we’re going to start with the white face.

I suggest you try to solve the first face without reading these instructions, so you can feel the sense of accomplishment when you complete it all alone. This step is not so hard because you don’t have to take care of so many solved cubelets yet.

You can determine where a piece comes according to the colour of the center pieces which never swap places. Every edge must fit to the side center piece too. See the attached image.

The idea is to put the first edge to the right spot, oriented correctly, then the second piece so you don’t mess up the one you have already solved. When you solve the fourth you have to take care not to mess up the three solved pieces so it gets harder step by step.You have to Do this Step By Yourself.

Step 2: How to solve the white corners in the first layer

Finishing the first layer of the Rubik’s Cube is still relatively easy and it can be used to familiarize with the puzzle without reading the cheat sheet.

The second step of the beginner’s Rubik’s Cube tutorial doesn’t require long algorithms. You just have to apply a couple of short permutations which are easy to understand and to memorize

03 How to solve the Rubiks Cube
The Cube Should Look Like This in The End

Here are a few examples which you might be facing while solving your Rubik’s Cube when you want to move a white corner piece to the top layer. In each example the piece we’re fixing is the last white corner to demonstrate that these moves don’t break the solved pieces.

According to the orientation there are three cases:

ALGORITHM: R’ D’ R
ALGORITHM: F D F’
OALGORITHM: R’ D2 R D R’ D’ R

ORIENTATION OF THE LAST(THIRD) LAYER

PERMUTATION OF LAST (THIRD) LAYER

Queue Data Structure(QDS)

Definition – QDS is a linear data structure which operates in a FIFO(First In First Out) or vise-versa LILO

Above is an image of QDS in memory.. Now we will discuss some operations…

STANDARD QUEUE OPERATIONS

  • enqueue();
  • dequeue();
  • isFull();
  • isEmpty();
  • count();

These were some operations if your reading this most probably you understand it…Now I will explain code theory…

//Initializations or declarations int arr[4]; int rear = -1; int front = -1; //operations isEmpty() { if(front == -1 && rear == -1) { return true; } else { return false; } } isFull() { if(rear == size(arr) – 1){ return true; } else{ return false; } } enqueue(value) { if(isFull()) { return; } else if(isEmpty()) { rear = 0; front = 0; } else { rear++; } arr[rear] = value; } dequeue() { int x = 0; if(isEmpty()) { return; } else if(front == rear) { x = arr[front] front = -1; rear = -1; } else { x = arr[front] front++; } return x; }

This was the code theory if you understand it it can not only be usedd in c++ but also python,java etc,etc….On my next post I will be giving examples to use in real life

Stack Data Structure

I was recently studying about data stuctures and algorithms in c++ in depth and then I learned to make simple stack data structure code to store 5 elements..I will giving the code in the end…Feel free to edit it..It is open source

Stack Data Structure aka SDS: Is is linear Data sturcture(DS: Data organization, management and storage format with efficent access and mod…)which operates as a LIFO(Lant In First Out) or vice versa FILO…

Some Standard Operations:

  • Push()
  • Pop()
  • isEmpty()
  • isFull()
  • peek()
  • count()
  • change()
  • display()

I’m afraid I’m not going to explain these operations but most of them are straight forward and some like push(), pop(), programmers will understand….This folders coantain a .txt and a .cpp file for editing and viewing the code AND a .exe file to run on your windows pc. CLICK ME FOR THE CODE

Design a site like this with WordPress.com
Get started