Friday, October 25, 2024

p::before{}

This should be behind "Testing ::before!"

Wednesday, October 23, 2024

Potential Energy Calculator

Potential Energy


Inputs:



Initial Position:

Last Position:


Potential Energy:

0


Kinetic Energy

0

Tuesday, October 22, 2024

Ping Pong Game [EN]

 In this blog, i will show u how to make ping pong game in Arduino.

Requirements:

Arduino Uno, Arduino IDE, Potentiometer, LCD OLED (0.92 inch, SSD1306), Buzzer


connection (image soon):







code:


#include "ssd1306.h"


//function "handleDirection" not working properly, fix it

const unsigned char playerLineIMG [] PROGMEM = {

  0xFF

};


const unsigned char ballIMG [] PROGMEM = {

  0b00000011,

  0b00000011

};


const int plrWidth = sizeof(playerLineIMG);

const int ballWidth = sizeof(ballIMG);


const int ballSpeed = 1;


const int toneDuration = 100;


const int toneFreq = 1046;



class Player {

  public:

    SPRITE playerTop = ssd1306_createSprite( 0, 0, plrWidth, playerLineIMG );

    SPRITE playerBottom = ssd1306_createSprite( 0, 0, plrWidth, playerLineIMG );


    void setPlrX(int x){

      playerTop.x = x;

      playerBottom.x = x;

    }


    void setPlrY(int y){

      playerTop.y = y;

      playerBottom.y = y + 8;

    }


    void drawPlr(){

      playerTop.draw();

      playerBottom.draw();

    }


    int getX(){

      return playerTop.x;

    }


    int getY(){

      return playerTop.y;

    }


    void erasePlrTrace(){

      playerTop.eraseTrace();

      playerBottom.eraseTrace();

    }

};


String handleDirection(String directionOfSprite, int spriteBounceFrom){

  if(directionOfSprite == "SE" && spriteBounceFrom == 3){

    return "NE";

  }else if (directionOfSprite == "SE" && spriteBounceFrom == 2){

    return "SW";

  }

  if(directionOfSprite == "SW" && spriteBounceFrom == 3){

    return "NW";

  }else if (directionOfSprite == "SW" && spriteBounceFrom == 4){

    return "SE";

  }

  if(directionOfSprite == "NE" && spriteBounceFrom == 1){

    return "SE";

  }else if (directionOfSprite == "NE" && spriteBounceFrom == 2){

    return "NW";

  }

  if(directionOfSprite == "NW" && spriteBounceFrom == 1){

    return "SW";

  }else if (directionOfSprite == "NW" && spriteBounceFrom == 4){

    return "NE";

  }

}




const int potPin1 = A0;

const int potPin2 = A1;




void setup() {

  Serial.begin(9600);

  

  ssd1306_setFixedFont(ssd1306xled_font6x8);

  ssd1306_128x64_i2c_init();

  ssd1306_clearScreen();


  pinMode(potPin1, INPUT);

  pinMode(potPin2, INPUT);


  SPRITE ball;

  ball = ssd1306_createSprite(0, 0, ballWidth, ballIMG);


  Player plr1, plr2;


  plr1.setPlrX(127);

  plr1.setPlrY(0);

  plr1.drawPlr();


  plr2.setPlrX(0);

  plr2.setPlrY(0);

  plr2.drawPlr();

  ball.x = 64;

  ball.y = 32;

  String BallDir = "SE";

  short int ballBounceFrom = 0; //0 == unknown, 1 == top, 2 == right, 3 == bottom, 4 == left


  short int pointPlr1 = 0, pointPlr2 = 0;

  

  for(;;){

    ssd1306_clearScreen();

    ball.eraseTrace();

    char buffer1[10];

    char buffer2[10];


    sprintf(buffer1, "%d", pointPlr1);

    sprintf(buffer2, "%d", pointPlr2);


    if(pointPlr2 >= 10){

      ssd1306_printFixed(41, 0, buffer2, STYLE_BOLD);

    }else{

      ssd1306_printFixed(47, 0, buffer2, STYLE_BOLD);

    }

    ssd1306_printFixed(55, 0, "-", STYLE_BOLD);

    ssd1306_printFixed(61, 0, buffer1, STYLE_BOLD);

    

    Serial.println(BallDir);


    if(ball.y >= 63){

      if(BallDir == "SE"){

        tone(6, toneFreq, toneDuration);

        ballBounceFrom = 3;

        BallDir = handleDirection(BallDir, ballBounceFrom);

      }else if(BallDir == "SW"){

        tone(6, toneFreq, toneDuration);

        ballBounceFrom = 3;

        BallDir = handleDirection(BallDir, ballBounceFrom);

      }

    }


    if(ball.y == 0){

      if(BallDir == "NE"){

        tone(6, toneFreq, toneDuration);

        ballBounceFrom = 1;

        BallDir = handleDirection(BallDir, ballBounceFrom);

      }else if(BallDir == "NW"){

        tone(6, toneFreq, toneDuration);

        ballBounceFrom = 1;

        BallDir = handleDirection(BallDir, ballBounceFrom);

      }

    }


    if(ball.x >= plr1.getX()){

      if(ball.y <= plr1.getY() + 16 && !(ball.y < plr1.getY())){

        if(BallDir == "NE"){

          tone(6, toneFreq, toneDuration);

          ballBounceFrom = 2;

          BallDir = handleDirection(BallDir, ballBounceFrom);

        }else if(BallDir == "SE"){

          tone(6, toneFreq, toneDuration);

          ballBounceFrom = 2;

          BallDir = handleDirection(BallDir, ballBounceFrom);

        }

      }else{

        tone(6, toneFreq, toneDuration);

        pointPlr2 += 1;

        ball.x = 63;

        ball.y = 31;

        BallDir = "SW";

      }

    }


    if(ball.x <= plr2.getX()){

      if(ball.y <= plr2.getY() + 16 && !(ball.y < plr2.getY())){

        tone(6, toneFreq, toneDuration);

        if(BallDir == "NW"){

          ballBounceFrom = 4;

          BallDir = handleDirection(BallDir, ballBounceFrom);

        }else if(BallDir == "SW"){

          tone(6, toneFreq, toneDuration);

          ballBounceFrom = 4;

          BallDir = handleDirection(BallDir, ballBounceFrom);

        }

      }else{

        tone(6, toneFreq, toneDuration);

        pointPlr1 += 1;

        ball.x = 63;

        ball.y = 31;

        BallDir = "SE";

      }

    }

    

    if(BallDir == "SE"){

        ball.x += ballSpeed;

        ball.y += ballSpeed;

    }else if(BallDir == "NE"){

      ball.x += ballSpeed;

      ball.y -= ballSpeed;

    }else if(BallDir == "SW"){

        ball.x -= ballSpeed;

        ball.y += ballSpeed;

    }else if(BallDir == "NW"){

        ball.x -= ballSpeed;

        ball.y -= ballSpeed;

    }

    

    ball.draw();

    int potVal1 = analogRead(potPin1);

    int potVal2 = analogRead(potPin2);


    plr1.setPlrY(map(potVal1, 0, 1023, 0, 52)); //Y max = 56

    plr1.drawPlr();


    plr2.setPlrY(map(potVal2, 0, 1023, 0, 52));

    plr2.drawPlr();

  }

}


void loop() {

}

Length converter

Length Converter

Result:


Load txt file

The data won't be sent to me


try to play text writer version here!

Write txt file

Save Text to File

Try to play text reader version here!

Calculator

0


Operation:

flexbox test

item1

item2

item3

item4

css test

 This text should have red color

This should have background color blue


This should have a border

JavaScript w/ button test

 

:)

Button Test

 

Introduction/Introduksi

    (Scroll untuk bahasa Indonesia)


    Hello! I am Ammonianimation, but you'll can call me Ammonia or Diplomat. I'm and my birthday date is 26/01 (DD/MM). I'm a male. I can speak Indonesian and English, but maybe it's a bit broken. I love science (except ecology and biotech), especially electricity ones. I also love IoT, and currently, I has made many projects, but the most notable project is altimeter, and ping pong. Maybe later I can give you'll, my code. I also love programming and I "speak" C++, Javascriptnese (Javascript) and Luanese (Lua). I making this blog for a project in school. See you later!


    Halo! Aku Ammonianimation, tapi kamu bisa memanggil saya Amonia atau Diplomat. Saya berumur , dan tanggal ultah saya adalah 26/01 (TT/BB atau DD/MM). Saya cowok. Saya bisa berbicara dalam bahasa Indonesia dan bahasa Inggris, tetapi mungkin sedikit tidak baku / tidak akurat. Saya suka IPA (kecuali ekologi dan biotek), apalagi kalau yang kelistrikan itu. Aku juga suka IoT, dan sekarang, saya sudah memmbuat banyak proyek, seperti altimeter dan ping pong. Mungkin saya akan memberi kodenya nanti. Saya juga menukai programming, dan saya "berbicara" bahasa C++, Javascript, dan Lua. Saya membuat blog ini untuk projek di sekolah. Sampai bertemu lagi!

List of operations that can be made out using Opamp (Operation Amplifier)

1. Inverting Amplifier
    Inverting Amplifier is a configuration of OpAmp that inverts and boosts the input.

Notable Formulas:
Gain = Rf/Rin
Vout     Rf
------ = -----
Vin       R1

2. Non - Inverting Amplifier
    Non - Inverting Amplifier is a configuration of OpAmp that boost the input
Notable Formulas:
Vout             Rf
------ = 1 + -------
Vin               R1

3. Differential Amplifier
    Differential Amplifier is a configuration of OpAmp that subtracts the inputs




 


Notable Formulas:

Vout     Rf
------ = -----
Vin       R1

4. Summing Amplifier
     Differential Amplifier is a configuration of OpAmp that sums the inputs










Notable formulas:
Vo = Rf((V1/R1) + (V2/R2) + ... + (Vn/Rn))

if R1 == R2 == ... == Rn == R:
Vo = -Rf/R(V1 + V2 + ... + Vn)

if R1 == R2 == .. == Rn == R == Rf
Vo = -(V1 + V2 + .. + Vn)

5. Integrator Amplifier
    Integrator Amplifier is a configuration of OpAmp that integrates the inputs










Notable Formula:
Vo = -(1/RC) ∫Vidt

Are you a Golfball kin?

are you a Golfball kin (very inaccurate) are you a Go...