Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

hocarm

🎯
Focusing
View GitHub Profile
View While_control.c
int main(void) {
unsigned long side; // room wall meters
unsigned long area; // size squared meters
UART_Init(); // call subroutine to initialize the uart
printf("This program calculates areas of square-shaped rooms\n");
side = 1;
while(side < 50){
area = Calc_Area(side);
printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area);
side = side+1;
View If_condition.c
unsigned long error;
// Tính diện tích căn phòng
// Input: kích thước căn phòng (unsigned long)
// Output: diện tích căn phòng (unsigned long)
// Notes: ...
unsigned long Calc_Area(unsigned long s) {
unsigned long result;
if(s <= 25){
result = s*s;
}else{
View Func_BottomUp.c
// Tính diện tích căn phòng hình vuông
// Input: Kích thước căn phòng (kiểu unsigned long) đơn vị mét
// Output: Diện tích căn phòng (kiểu unsigned long) đơn vị mét vuông
unsigned long Calc_Area(unsigned long s) {
unsigned long result;
result = s*s;
return(result);
}
int main(void) {
unsigned long side; // Kích thước căn phòng
View Func_TopDown.c
unsigned long Calc_Area(unsigned long s);
int main(void) {
unsigned long side; // độ dài bức tường đơn vị met
unsigned long area; // diện tích căn phòng đơn vị met vuông
UART_Init(); // gọi subroutine để init uart
printf("This program calculates areas of square-shaped rooms\n");
side = 3;
area = Calc_Area(side);
printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area);
side = side+2;
View C_arithmetic_operator.c
void main(void){
long x,y,z; // 3 biến x y z là local variables
x=1; y=2; // set giá trị của x và y
z = x+4*y; // tính z
x++; // Tăng x, cái này giống x=x+1;
y--; // Tương tự giảm y, giống y=y-1;
x = y<<2; // Dịch trái, tương tự x=4*y;
z = y>>2; // Dịch phải, tương tự x=y/4;
y += 2; // Tăng y, tương tự y=y+2;
}
View Blynk_ESP8266_AT_Command.ino
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
View square_rom.c
int main(void) {
unsigned long side; // Chieu dai cua can phong
unsigned long area; // Dien tich can phong
UART_Init(); // Gọi ham de init uart
side = 3;
area = side*side;
printf("\nDien tich cua can phong chieu dai %ld m la %ld m2\n",side,area);
}
View sample_embedded.c
//**** 0. Documentation Section
// This program calculates the area of square shaped rooms
// Author: Ramesh Yerraballi & Jon Valvano
// Date: 6/28/2013
//
// 1. Pre-processor Directives Section
#include <stdio.h> // Diamond braces for sys lib: Standard I/O
#include "uart.h" // Quotes for user lib: UART lib
// 2. Global Declarations section
View Delay_ns_us_ms.c
uint32_t counter_1ms;
void Delay_ns(__IO uint32_t nCount)
{
while(nCount--)
{
}
}
View AWS-ESP8266.ino
#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include "ESP8266AWSImplementations.h"
Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;
AmazonIOTClient iotClient;
ActionError actionError;