Skip to content

Instantly share code, notes, and snippets.

function [dx, y] = DCMotor(t,x,u,c,k,y_pic,varargin)
dx = [ x(2);
-(c)*x(2) + k*u(1)];
y = y_pic;
end
#include <iostream>
using namespace std;
int main(){
int a = 4;
int b = 2;
int c = a * b;
cout << c << endl;
}
int x = 10; // ตัวแปรชนิด จำนวนเต็ม เช่น เต็มบวก เต็มลบ เต็ม 0
float y = 12.2; // ตัวแปรชนิด จำนวนทศนิยม
char n = 'a'; // ตัวแปรชนิด ตัวอักษร ตัวแปรนี้จะเก็บได้แค่ตัวอักษรเดียวเท่านั้น
char* name = "RoboticsZa" // ตัวแปรชนิด string หรือข้อความ ตัวแปรนี้จะใช้ตัวแปร char ที่เก็บได้ตัวเดียวนั้น มาต่อ ๆ กันจนกลายเป็นข้อความ
bool iAmRobot = true // ตัวแปรชนิด boolean เป็นตัวแปรที่มีแค่ 2 ค่า คือจริง และ เท็จเท่านั้น
x = 10
y = 20
c = x + y
c = x / y
c = x * y
c = x - y
c = 2*x+y
c = (x/2) * y
x = 10
y = 20
c = x + y
#include <stdio.h> //Prepocessor Directives
void testHello(); // Global Decarations
int id_student = 10; // Global Decarations
int main(){
char* name = "RoboticsZa"; // Local Declarations
cout << "Hello World " << name <<endl; // Statements
return 0;
}
int angle = 0;
void drawTraingle(float x, float y , float radian){
float angleA = angle + 120 > 360? (angle + 120) - 360 : angle + 120; // เช็คว่าองศามากกว่า 360 หรือเปล่า ถ้ามากกว่า ก็จะให้กลับมาเริ่ม 0 ใหม่
float Ax = cos(radians(angleA)) * radian;
float Ay = sin(radians(angleA)) * radian;
float angleB = angle + 240 > 360? (angle + 240) - 360 : angle + 240; // เช็คว่าองศามากกว่า 360 หรือเปล่า ถ้ามากกว่า ก็จะให้กลับมาเริ่ม 0 ใหม่
float Bx = cos(radians(angleB)) * radian;
float By = sin(radians(angleB)) * radian;
float newX = 0.0;
float newY = 0.0;
float oldX = 0.0;
float oldY = 0.0;
boolean isDrawFirst = true;
int angle = 0;
void drawCircle(float x, float y , float radian){
@vixtory09678
vixtory09678 / draw_triangle.java
Last active January 3, 2018 10:14
draw_triangle.java
void drawTriagle(float sideLength , float xOrigin , float yOrigin){
stroke(0);
float sideBx = sideLength / 2.0 * -1;
float sideBy = sqrt(pow(sideLength,2) - pow(sideBx,2));
float Bx = xOrigin + sideBx;
float By = yOrigin + sideBy;
line(xOrigin,yOrigin,Bx,By ); // วาดจากจุด Axy ไปจุด Bxy
float sideCx = sideLength / 2.0;
/* Create a WiFi access point and provide a web server on it. */
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#define buffer_size 22
#define period_udp 1
#define period_led 1000