어우.. 직장인이 가장 싫어하는 요일(!)

거의 10일 만에 출근하려니 겁.나.싫.다!

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

10월의 시작  (0) 2025.10.01
멘탈 크래시 크래시  (0) 2025.09.18
복리 / 단리  (0) 2025.09.17
외근  (0) 2025.09.09
압박붕대  (2) 2025.08.25
Posted by 구차니
embeded/arduino(genuino)2025. 10. 11. 21:01

아두이노 나노 v3.0 이고, 아래의 셋팅으로 진행함

 

라이브러리 매니저에서 servo / arduino 를 설치하고

 

귀찮으니 D5/D6/D9/D10 옮겨가며 해보는걸로 하고, 일단은 날로 먹기 모드 ㅋㅋ

 

아래 코드를 대충 작성해서 넣어주면

#include <Servo.h>

Servo myservo[4];
String inputString = "";
bool stringComplete = false; 
unsigned char pwm_ch[4] = {5,6,9,10};
unsigned char pwm_val[4] = {127,127,127,127};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello");
  
  inputString.reserve(200);

  for(int idx = 0;idx < 4;idx++)
  {
      myservo[idx].attach(pwm_ch[idx]);
      myservo[idx].write(pwm_val[idx]);
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  if (stringComplete) {
    char data[64] = "";
    inputString.toCharArray(data, inputString.length());
    sscanf(data, "%d,%d,%d,%d\n",
      &(pwm_val[0]),
      &(pwm_val[1]),
      &(pwm_val[2]),
      &(pwm_val[3]));

    char res[64] = "";
    sprintf(res, "get %d %d %d %d\n", pwm_val[0], pwm_val[1], pwm_val[2], pwm_val[3]);
    Serial.print(res);

    Serial.print(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;

    for(int idx = 0;idx < 4;idx++)
    {
      if(pwm_val[idx] > 255) pwm_val[idx] = 255;
      if(pwm_val[idx] < 1) pwm_val[idx] = 1;
      myservo[idx].write(pwm_val[idx]); 
    }
  }
}

void serialEvent()
{
  while(Serial.available())
  {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n')
    {
      stringComplete = true; 
    }
  }
}

 

최초 구동시 Hello가 나오고

콤마로 4개의 값을 넣어주면 된다. 개별 범위는 0~255

[링크 : https://docs.arduino.cc/learn/electronics/servo-motors/]

 

그나저나 pinMode 설정과 analogWrite() 로는 정상적으로 작동하지 않네.. 머가 문제일까?

int ledPin = 9;      // LED connected to digital pin 9
int analogPin = A0;  // potentiometer connected to analog pin A0
int val = 0;         // variable to store the read value

void setup() {
  pinMode(ledPin, OUTPUT);  // sets the pin as output
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}

[링크 : https://support.arduino.cc/hc/en-us/articles/9350537961500-Use-PWM-output-with-Arduino]

 

그래서 찾아보니

servo는 대부분 pwm이 아니라는 이야기. 아.. 그렇지! pwm이 아니지?!

[링크 : https://forum.arduino.cc/t/analogwrite-vs-servo-write/370486/3]

[링크 : https://forum.arduino.cc/t/servo-with-analogwrite/438505/7]

'embeded > arduino(genuino)' 카테고리의 다른 글

아두이노 시리얼 이벤트 핸들러  (0) 2025.10.09
퀄컴 아두이노 인수  (0) 2025.10.08
아두이노 sd 카드  (0) 2025.08.24
skt-444 콘덴서 마이크 모듈 분해  (0) 2025.08.07
HW-504 이상해..  (0) 2025.08.02
Posted by 구차니
Programming/C Win32 MFC2025. 10. 11. 18:22

대부분의 경우 소수점 자리만 제한하는데

정수쪽도 길이 제한할일이 있어서 찾아보는데 묘하게 자료가 없어서 테스트 해봄

다만 리눅스에서 한거라 윈도우에서는 다를수 있음

 

void main()
{
	float a = -12.12334;
	printf("%f\n", a);
	printf("%4.1f\n",a);
	printf("%5.1f\n",a);
	printf("%6.1f\n",a);

	printf("%7.1f\n",a);
 	printf("%7.2f\n",a);
	printf("%7.3f\n",a);
   
	printf("%9.1f\n",a);
	printf("%9.2f\n",a);
	printf("%9.3f\n",a);
}

 

$ ./a.out 
-12.123340
-12.1
-12.1
 -12.1
  -12.1
 -12.12
-12.123
    -12.1
   -12.12
  -12.123

 

 

%7.1f / %7.2f / %7.3f 와

%9.1f / %9.2f / %9.3f 가

어떻게 보면 내가 하고 싶었던 결과인데 자리를 정리하면 아래와 같이 나온다.

  1 2 3 4 5 6 7 8 9
%7.3f - 1 2 . 1 2 3    
%9.3f     - 1 2 . 1 2 3

 

정리하자면

%n.mf 에서

n은 정수 부분, 소수점, 부호 를 포함한 전체 길이이고

m은 그중 소수점의 자릿수. m은 n 보다 작아야 한다.

 

'Programming > C Win32 MFC' 카테고리의 다른 글

free(): invalid next size (normal)  (0) 2023.12.18
c에서 cpp 함수 불러오기  (0) 2023.01.04
MSB / LSB 변환  (0) 2022.08.29
kore - c restful api server  (1) 2022.07.07
fopen exclusivly  (0) 2021.07.09
Posted by 구차니

대충~ 3.10 부터 추가되었다는 이야기

 

def http_error(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"
Note the last block: the “variable name” _ acts as a wildcard and never fails to match. If no case matches, none of the branches is executed.

You can combine several literals in a single pattern using | (“or”):

case 401 | 403 | 404:
    return "Not allowed"

class Point:
    x: int
    y: int

def where_is(point):
    match point:
        case Point(x=0, y=0):
            print("Origin")
        case Point(x=0, y=y):
            print(f"Y={y}")
        case Point(x=x, y=0):
            print(f"X={x}")
        case Point():
            print("Somewhere else")
        case _:
            print("Not a point")

[링크 : https://docs.python.org/ko/3.10/tutorial/controlflow.html#match-statements]

[링크 : https://okeybox.tistory.com/395]

[링크 : https://leapcell.io/blog/ko/python-eseo-switch-muneul-jakseonghaneun-bangbeop-2025-switch-case-yeeje]

[링크 : https://www.bangseongbeom.com/python-switch-case]

 

PEP - Program Enhance Proposal

[링크 : https://wikidocs.net/7896]

 

2020년에 작성되었고, 3.10 버전에 추가됨.

PEP 636 – Structural Pattern Matching: Tutorial
Author: Daniel F Moisset <dfmoisset at gmail.com>
Sponsor: Guido van Rossum <guido at python.org>
BDFL-Delegate:
Discussions-To: Python-Dev list
Status: Final
Type: Informational
Created: 12-Sep-2020
Python-Version: 3.10
Post-History: 22-Oct-2020, 08-Feb-2021
Resolution: Python-Committers message

[링크 : https://peps.python.org/pep-0636/]

 

아니 본인이 2006년에 썼다가 reject 했어?

PEP 3103 – A Switch/Case Statement
Author:Guido van Rossum <guido at python.org>
Status:Rejected
Type:Standards Track
Created:25-Jun-2006
Python-Version:3.0
Post-History:26-Jun-2006

[링크 : https://peps.python.org/pep-3103/]

'Programming > python(파이썬)' 카테고리의 다른 글

python simsimd  (0) 2025.08.28
python 원하는 버전 설치 및 연결하기  (0) 2025.08.26
pip 패키지 완전 삭제하기  (0) 2025.08.13
pip install cmake build multi core support  (0) 2025.08.13
python 빌드 정보  (0) 2025.08.04
Posted by 구차니
embeded/arduino(genuino)2025. 10. 9. 22:44

예제로 맨날 폴링만 보다보니 인터럽트가 될거라 생각을 못했네..

/*
  SerialEvent occurs whenever a new data comes in the hardware serial RX. This
  routine is run between each time loop() runs, so using delay inside loop can
  delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag so the main loop can
    // do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

 

[링크 : https://docs.arduino.cc/built-in-examples/communication/SerialEvent]

[링크 : https://juahnpop.tistory.com/85]

[링크 : https://m.blog.naver.com/dhtpals32123/222270427302]

'embeded > arduino(genuino)' 카테고리의 다른 글

arduino nano로 4채널 pwm 출력하기  (0) 2025.10.11
퀄컴 아두이노 인수  (0) 2025.10.08
아두이노 sd 카드  (0) 2025.08.24
skt-444 콘덴서 마이크 모듈 분해  (0) 2025.08.07
HW-504 이상해..  (0) 2025.08.02
Posted by 구차니

망할(?) 케이팝 데몬 헌터스의 영향으로 추석 마지막 날에도 한국인/외국인들이 넘쳐났다.

10년 전에는 자전거타고 침흘리며 올라갔는데, 드디어(!) 버스를 타고 올라와봄

 

장충체육관 쪽에서 01A 01B를 타려고 한 7대 보내고

부랴부랴 타고 올라와서 애들이 힘들줄을 모르는 듯 ㅋㅋㅋ

 

 

저 멀리(?) 너무 잘 보이는 롯데타워

 

 

'개소리 왈왈 > 사진과 수다' 카테고리의 다른 글

눈 @.@  (0) 2024.11.27
부웨에에에에엑~  (0) 2024.10.16
캐논 카메라 sd 카드 쓰기 잠금 문제  (0) 2024.06.20
크랍바디에 대한 오해가 있었구나..  (0) 2024.06.17
eos 웹캠 유틸리티  (0) 2024.06.16
Posted by 구차니
embeded/raspberry pi2025. 10. 9. 18:47

SPI LCD를 한번 써보고 싶어서(직접 드라이버 구현)

일단은 장치가 문제없나 확인부터 해보고 스펙 확인겸~ 남이 만든거 쓱쓱~

 

준비물

라즈베리 파이 피코 / 1.8 TFT SPI 128x160 이라고 써있는 LCD 보드

그냥 싸서 샀는데 color TFT LCD 이다.

 

라즈베리 파이 피코 핀아웃. 오랫만에 하니 헷갈려서 봤는데

정작 이건 참고 안하고 보드에 실크보고 해결 ㅋㅋ

[링크 : https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html]

 

결선은 아래와 같이 하면 된다.

LED는 백라이트다. 뽑는다고 LCD 컨트롤러가 죽진 않는다.

TFT Board => Raspberry Pi Pico Pin
LED => 3v3(Out)
SCK => GP10
SDA => GP11
AO/DC => GP16
Reset => GP17
CS => GP18
GND => GND
VCC => VBUS 5V

[링크 : https://alastairmontgomery.medium.com/tft-display-st7735-with-micropython-ef48ecbfc278]

 

라즈베리 파이 피코

 

 

LCD

 

윈도우에서 thonny 깔고, tool - options - interpreter 에서 micropython (Raspberry Pi Pico) 선택

아래 포트는 확인하고 설정하던가 귀찮으면 try to detect port automatically 하면 끝.

[링크 : https://thonny.org/]

 

bootsel 누른채로 꽂아서 다음에서 다운로드 한 uf2 파일을 던져주면 끝

[링크 : https://www.raspberrypi.com/documentation/microcontrollers/micropython.html]

 

아래 프로젝트를 다운로드 해서

[링크 : https://github.com/alastairhm/micropython-st7735]

  [링크 : https://alastairmontgomery.medium.com/tft-display-st7735-with-micropython-ef48ecbfc278]

 

thonny 에서 view - files 하면 탐색기 뜨고 그걸로 업로드 하면 된다.

 

graphicstest 실행시 아래의 것들이 순차적으로 실행된다.

 

 

 

이거 하나 채워지는데 제법 오래걸린다.

 

 

tftbmp 실행시. 체감상 다 그려지는데 한 5초?

 

mandelbrot_tft 실행시. 그리고 표시하는지 한 10초 걸리는 듯

 

 


----

circuitpython usb fs 미지원?

[링크 : https://forums.raspberrypi.com/viewtopic.php?p=1812620#p1812620]

 

혹시나 해서 윈도우에서 thonny나 pip 안깔고 되나했는데

이래저래 귀찮을 듯 해서 포기하고 thonny 설치하는 걸로 해결 -_-

[링크 : https://mikeesto.medium.com/uploading-to-the-raspberry-pi-pico-without-thonny-53de1a10da30]

[링크 : https://github.com/dhylands/rshell]

Posted by 구차니
embeded/전자회로2025. 10. 8. 22:21

이번에 하나를 산 거 같은데 정리하다 보니 두 개가 나와서 이력을 찾아보니

아니 왜 산걸 까먹고 또 산겨 -_-

머 덕분에 멀티 adc를 이용한 채널 확장도 해볼순 있겠네

 

'embeded > 전자회로' 카테고리의 다른 글

열전대 써모커플러  (0) 2025.07.17
buzzer - 액티브 패시브  (0) 2025.07.15
rheostat ?  (0) 2024.07.25
notch filter  (0) 2024.05.21
멀티미터 TR 테스트  (0) 2023.11.02
Posted by 구차니
embeded/arduino(genuino)2025. 10. 8. 22:15

어떤 의미로 놀랍긴 한데.. wiring 기반으로 발전해왔고

라즈베리에서도 wiring을 잘 썼는데

퀄컴이 아두이노 인수하면서 어떻게 될지가 좀 조심스러워진다.

[링크 : https://news.hada.io/topic?id=23502]

[링크 : https://www.techpowerup.com/341673/qualcomm-to-acquire-arduino]

 

눈에 띄는건.. Adreno GPU 3D 가속기와 카메라 2개 가능, cortex-M33 160Mhz 별도 장착.

Core
Qualcomm Dragonwing™ QRB2210
Includes the powerful Qualcomm Dragonwing™ QRB2210 processor featuring:
Quad-core Arm® Cortex®-A53 @ 2.0 GHz
Adreno GPU 3D graphics accelerator
2x ISP (13 MP + 13 MP or 25 MP) @ 30 fps
Overview
Microcontroller
STM32U585 Arm® Cortex®-M33 32-bit MCU
The UNO Q integrates the STM32U585 microcontroller featuring:
Arm® Cortex®-M33 up to 160 MHz
2 MB flash memory
786 kB SRAM
Floating Point Unit

[링크 : https://docs.arduino.cc/hardware/uno-q/]
[링크 : https://www.arduino.cc/product-uno-q] UNO Q

 

가격이 낮아질것 같진 않지만.. 일단 아두이노가 라즈베리를 타겟으로 하는 가격을 보여주는 듯.

[링크 : https://store-usa.arduino.cc/products/uno-q]

 

 

'embeded > arduino(genuino)' 카테고리의 다른 글

arduino nano로 4채널 pwm 출력하기  (0) 2025.10.11
아두이노 시리얼 이벤트 핸들러  (0) 2025.10.09
아두이노 sd 카드  (0) 2025.08.24
skt-444 콘덴서 마이크 모듈 분해  (0) 2025.08.07
HW-504 이상해..  (0) 2025.08.02
Posted by 구차니
프로그램 사용/ntopng2025. 10. 6. 11:53

네트워크 맵을 그려주길래 보고 있었는데 10분 지나니 이렇게 된다. -_-

 

dashboard는 빼먹었는데 먼가 몇 개 그래프가 사라진거 같고

메뉴상에서 확인해보면 생각외로 많은 것들이 잠긴다.

Enterprise XL community

 

'프로그램 사용 > ntopng' 카테고리의 다른 글

ntopng ubuntu 22.04 신버전 설치  (0) 2025.10.06
ntopng nic 어디서 봐야하나?  (0) 2025.10.06
ntopng 인터페이스 변경  (0) 2025.10.05
Posted by 구차니