Code Monkey home page Code Monkey logo

binaryprinter's Introduction

BinaryPrinter

made by Wooseok Diaa Hwang

소개

매우매우 간단한 이진수 출력기

이진수에서 1이 있는 자릿수 그대로 LED에 출력하는 코드

ex) 00000101 -> LED 1, 3번재 핀 점등

보드

Nucleo-F103RB

  • 클럭: 72MHz
  • 사용 핀
    • A8 : GPIO-OUTPUT / No Pull
    • B10 : GPIO-OUTPUT / No Pull
    • B4 : GPIO-OUTPUT / No Pull
    • B5 : GPIO-OUTPUT / No Pull
    • B3 : GPIO-OUTPUT / No Pull
    • A10 : GPIO-OUTPUT / No Pull
    • B15 : GPIO-OUTPUT / No Pull
    • B14 : GPIO-OUTPUT / No Pull

코드

전역변수

typedef struct led_t {
	GPIO_TypeDef *port;
	int pin;
}led_t;

led_t led[8] = {
	{GPIOA, GPIO_PIN_8},
	{GPIOB, GPIO_PIN_10},
	{GPIOB, GPIO_PIN_4},
	{GPIOB, GPIO_PIN_5},
	{GPIOB, GPIO_PIN_3},
	{GPIOA, GPIO_PIN_10},
	{GPIOB, GPIO_PIN_15},
	{GPIOB, GPIO_PIN_14},
};

void allDown() {
	for(int k = 0; k<8; k++) {
		HAL_GPIO_WritePin(led[k].port, led[k].pin, RESET);
	}
}

main() -> while 전 USER CODE

uint32_t i, status;

while문

for(i = 0; i<=255; i++) {
    for(status = 0; status < 8; status++) {
        if((i >> status) % 2 != 0) {
            HAL_GPIO_WritePin(led[status].port, led[status].pin, SET);
        }
    }
    HAL_Delay(50);
    allDown();
}

binaryprinter's People

Contributors

diaa-woo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.