Logo

Build Embedded
with
AI Intelligence

UnityMbed ขับเคลื่อนด้วย AI สู่ Ecosystem เดียวที่จบทุกขั้นตอนตั้งแต่เขียนโค้ดจนถึงแฟลชลงบอร์ด ช่วยให้คุณพัฒนาระบบ Embedded Systems ได้ฉลาดและเร็วกว่าที่เคย

เขียน Build และแฟลชในเซสชันเดียว

เซสชันจริงบน N32G031: GPIOA clocks, เชื่อมต่อ DHT11 และแฟลชได้ในคลิกเดียว

UM
N32G031_OLED_DHT11-mainn32g031
>เชื่อมต่อกับดิสก์ · ~/Projects/N32G031_OLED_DHT11
ไฟล์โครงการ
ไฟล์โครงการ
src
7
misc.c
n32g031_it.c
oled.c
system_n32g031.c
utils.c
drivers
51
filemain
2
inc
10
เครื่องมือ
ฮาร์ดแวร์
2
ชุดเครื่องมือ
1
คลาวด์
3
บัญชี
4
ขั้นสูง
2
⌘Kค้นหาด่วน
main.c✕
src/main.c
AI ทำงานอยู่
1#include "n32g031.h"
2#include "n32g031_gpio.h"
3#include "n32g031_rcc.h"
4#include "core_cm0.h"
5#include "dht11.h"
6#include "oled.h"
7#include "utils.h"
8#include <stdio.h>
9
10// --- ADDED: LED Initialization ---
11void leds_init(void)
12{
13 // Enable GPIOA clock (Bit 2 in APB2PCLKEN)
14 RCC->APB2PCLKEN |= (1U << 2);
15
16 // Configure PA2 (Yellow), PA3 (Green), PA4 (Red) as Output (01)
17 GPIOA->PMODE &= ~((3U << 4) | (3U << 6) | (3U << 8));
18 GPIOA->PMODE |= ((1U << 4) | (1U << 6) | (1U << 8));
19
20 // Configure as Push-Pull (0)
21 GPIOA->POTYPE &= ~((1U << 2) | (1U << 3) | (1U << 4));
22
23 // Configure No Pull-up/Pull-down (00)
24 GPIOA->PUPD &= ~((3U << 4) | (3U << 6) | (3U << 8));
25
26 // Turn all LEDs OFF initially (write 1 to Port Bit Clear register)
27 GPIOA->PBC = (1U << 2) | (1U << 3) | (1U << 4);
28}
29// ---------------------------------
30
31int main(void)
32{
33 uint8_t current_temp = 0;
34 uint8_t current_humi = 0;
35
36 uint8_t last_temp = 255;
37 uint8_t last_humi = 255;
38 uint8_t was_error = 1;
39
40 uint8_t error_count = 0;
41
42 char buffer[20];
43
44 SystemInit();
45 SystemCoreClockUpdate();
46
47 leds_init(); // Initialize the 3 LEDs
48
49 delay_ms(500);
50 OLED_Init();
51 OLED_Clear();
52 DHT11_Init();
53
54 OLED_ShowString(10, 24, "System Ready", 16);
55 delay_ms(1500);
56
57 OLED_Clear();
58
59 while (1)
60 {
61 if (DHT11_Read_Data(&current_temp, &current_humi) == 1)
62 {
63 error_count = 0;
64
65 if (was_error)
66 {
67 OLED_Clear();
68 OLED_ShowString(0, 0, "Temp: ", 8);
69 OLED_ShowString(0, 32, "Humidity: ", 8);
70 was_error = 0;
71 last_temp = 255;
72 last_humi = 255;
73 }
74
75 if (current_temp != last_temp)
76 {
77 sprintf(buffer, "%02d C ", current_temp);
78 OLED_ShowString(0, 12, buffer, 16);
79 OLED_ShowString(24, 12, "o", 8);
80 last_temp = current_temp;
81 }
82
83 if (current_humi != last_humi)
84 {
85 sprintf(buffer, "%02d %% ", current_humi);
86 OLED_ShowString(0, 44, buffer, 16);
87 last_humi = current_humi;
88 }
89
90 // --- ADDED: LED Logic based on Humidity ---
91 if (current_humi < 40)
92 {
93 GPIOA->PBSC = (1U << 3); // Green ON (PA3)
94 GPIOA->PBC = (1U << 2) | (1U << 4); // Yellow, Red OFF
95 }
96 else if (current_humi >= 40 && current_humi <= 60)
97 {
98 GPIOA->PBSC = (1U << 2); // Yellow ON (PA2)
99 GPIOA->PBC = (1U << 3) | (1U << 4); // Green, Red OFF
100 }
101 else
102 {
103 GPIOA->PBSC = (1U << 4); // Red ON (PA4)
104 GPIOA->PBC = (1U << 2) | (1U << 3); // Green, Yellow OFF
105 }
106 // ------------------------------------------
107 }
108 else
109 {
110 error_count++;
111
112 if (error_count >= 3)
113 {
114 if (!was_error)
115 {
116 OLED_Clear();
117 was_error = 1;
118 }
119 OLED_ShowString(0, 0, "Sensor Error! ", 16);
120 OLED_ShowString(0, 24, "Check Wiring. ", 16);
121
122 // Optional: Turn off all LEDs on error
123 GPIOA->PBC = (1U << 2) | (1U << 3) | (1U << 4);
124 }
125 }
126
127 delay_ms(2000);
128 }
129}
AI ASSISTANT
N32G031 เชื่อมต่อแล้วPro ctx 0.0k

แฟลชลงบอร์ด N32G031

Starter, Pro และ Learning ใช้ Cortex-M0+ ชุดเดียวกัน หมุนดูบอร์ด แล้วสั่งจากฟอร์มด้านล่าง

Starter Kit Board

มาในรูปทรงคลาสสิกแบบบอร์ด Uno (Uno-style footprint) ทำให้สามารถใช้งานร่วมกับฮาร์ดแวร์ชีลด์ (Shields) ทั่วไปตามท้องตลาดได้อย่างลงตัว

เหมาะสำหรับผู้เริ่มต้นPlug & Playครบจบในบอร์ดเดียว

Partners

Thammasat University Logo
KOSEN - KMITL Logo
EEI Logo
ES Logo
ThaiEasyElec Logo
XZEN Logo
NSING Logo
API TECH Logo
Thammasat University Logo
KOSEN - KMITL Logo
EEI Logo
ES Logo
ThaiEasyElec Logo
XZEN Logo
NSING Logo
API TECH Logo
Thammasat University Logo
KOSEN - KMITL Logo
EEI Logo
ES Logo
ThaiEasyElec Logo
XZEN Logo
NSING Logo
API TECH Logo
Thammasat University Logo
KOSEN - KMITL Logo
EEI Logo
ES Logo
ThaiEasyElec Logo
XZEN Logo
NSING Logo
API TECH Logo

เลือกแพ็กเกจ

สมัครแล้ว?Sign in เพื่อจัดการแพ็กเกจ →

โมเดล AI ที่ใช้ได้ขึ้นอยู่กับแพ็กเกจ ดูโมเดลที่รวมอยู่ในแต่ละแพ็กเกจ
เปรียบเทียบแพ็กเกจ
Free
Starter
Pro
แนะนำยอดนิยม
Advance
Enterprise
ราคา
ฟรี
฿249/เดือน
฿550/เดือน
฿990/เดือน
กำหนดเอง
จำนวนผู้ใช้1 ผู้ใช้1 ผู้ใช้1 ผู้ใช้1 ผู้ใช้ระบุจำนวนที่นั่งได้ตามโครงสร้างจริงขององค์กร
เครดิต200 เครดิต2,000 เครดิต7,000 เครดิต13,000 เครดิตเครดิตแบบกำหนดเอง
การเข้าถึงโมเดล AIFastFastFast · Balanced · SmartFast · Balanced · Smart · ProFast · Balanced · Smart · Pro
ความยืดหยุ่นเหมาะสำหรับทดลองใช้เหมาะสำหรับใช้งานทั่วไปเหมาะสำหรับใช้งานเป็นประจำเหมาะสำหรับงานระดับสูง
ปรับแต่งตามความต้องการขององค์กร
บริการช่วยเหลือระดับพรีเมียม

ติดตั้ง IDE บนเดสก์ท็อป

WINDOWS 10/11

Windows

MACOS 12+

Mac OS

ANY DISTRO

Linux

GET IN TOUCH

เบอร์โทรศัพท์

เวลาทำการ

จันทร์ - ศุกร์: 09:00 - 20:00 น.

หยุดวันเสาร์-อาทิตย์ และวันหยุดนักขัตฤกษ์

ติดตามช่องทางของเรา
GitHubLINETikTok