★筆記☆
★Maker Uno★
驅動程式:https://drive.google.com/drive/folders/14D0rOGH9dPRZlPg00534giOeToXpGGex?fbclid=IwAR2jYgvB8MsinzpXtoz7c_35iNkN4UADYAAQNqTPJJcmH6lKI6Z7ITsmAhQ
範例:https://github.com/CytronTechnologies/MakerUno_Examples/blob/master/MakerUno_DefaultSketch/MakerUno_DefaultSketch.ino?fbclid=IwAR1NL7pHBGsbsLO-_zI4V230QO6Z5EdgXXDrMRkWkbNCmXjk0i2x1yocDzw
☆☆
工具->顏色選擇器。
void setup(){} //大約等於Strat()
void draw(){} //大約等於Update()
line()//劃一條線,從開始點的XY座標,到結束點的XY座標。
rect()//畫一個長方形,從開始點的XY座標,到結束點的XY座標。
fill()//方格填色,A(RGBA)方式ORB(#??????)色碼填色。
background()//背景填色,A(RGBA)方式ORB(#??????)色碼填色。
ellipse()//橢圓形(起點(XY)座標,長,寬。)
圖片的載入處理:
- PImage img;增加圖片近來,先進行宣告
- img=loadImage("dora.jpg");讀入圖片
image(img,0,0,width,height);顯示圖片
右鍵刪除:
- if (mousePressed&& mouseButton == RIGHT) { //如果是右鍵,那就把格子填白
- int nowX=mouseX/16*16 , nowY=mouseY/30*30; //偵測在哪個位置,將小數消掉之後讓方格基點在左上角
mouseDragged()//滑鼠移動函式
key//用來偵測鍵盤的按鍵
keyCode//用來偵測沒辦法直接打出來的按鍵 UP RIGHT ALT CTRL ENTER 之類的
可以使用PRINT來偵測KEY OR KEYCODE//可能會因為系統差異而有不同編碼
多用變數取代定值,可以更方便更改。
keyReleased//按鍵跳起來後執行
import processing.sound.*;
圖片的留白處理:
- 把圖片讀入近PPT
- PPT的相片處理效果可以決定要把哪些背景去掉
- 把處理好的相片下載回來
- 放入程式
imageMode(CENTER);//圖片的中心點
user =new PVector(200,200);//向量
userV=new PVector(1,1);
elipse(user.X,user.Y,100,100);
user.add(userV);
userV=new PVector(1,1);
elipse(user.X,user.Y,100,100);
user.add(userV);
PIXELS:
(1):A=loadImage();
(2):A.loadPixels();
(3):a.pixels[mouseX+mouseY*螢幕寬度] //這個點的顏色。
聲音載入法:
- SoundFile player;
player = new SoundFile(this,"Dora.mp3");
player.play();
}
pinMode(13, OUTPUT); // sets the digital pin 13 as output
digitalWrite(13, HIGH); // sets the digital pin 13 on
#define NOTE_C5 523//DO
#define NOTE_D5 587//RE
#define NOTE_E5 659//ME
#define NOTE_F5 698//FA
#define NOTE_G5 784//SO
#define NOTE_A5 880//LA
#define NOTE_B5 988//SI
☆☆★★
int Do=523;int Re=587;
int Mi=659;
int Fa=698;//FA
int So=784;
int La=880;
int Si=988;
int DoP=1046;
int ReP=1109;
int MiP=1175;
int FaP=1245;
int Melody[]={Do,Re,Mi,Fa,So,La,0,Si,DoP,ReP,MiP,FaP};
void setup() {
// put your setup code here, to run once:
for(int i=2;i<=13;i++){
pinMode(i,INPUT_PULLUP);
}
pinMode(8, OUTPUT);
}
int alpha=0;
void loop() {
for(int i=2;i<=13;i++){
if(i==8)continue;
if(digitalRead(i)==LOW){tone(8,Melody[i-2],300);}
}
}
☆☆★★
void setup(){
pinMode(2,INPUT);
}
void loop(){
analogRead(A0);
analogRead(A1);
digitalRead(2);
}
☆☆★★
GND->GND
5V->5V
A0->X
A1->Y
☆☆★★
void setup() {
Serial.begin(9600);
}
void loop() {
int x=analogRead(A0);
int y=analogRead(A1);
Serial.print(x);
Serial.print(" ");
Serial.print(y);
Serial.println();
delay(100);
}
========待修正======
import processing.net.*;
Client client;
ArrayList<PVector>points;
int alpha=0;
void setup(){
size(800,600);
client =new Client(this,"127.0.0.1",7777);
points = new ArrayList<PVector>();
}
void draw(){
background(255);
/*if(mousePressed){
line(mouseX,mouseY,pmouseX,pmouseY);
client.write(mouseX+" "+mouseY+" "+pmouseX+" "+pmouseY+"\n");
}*/
for(int i=0;i<points.size();i++){
ellipse(points.get(i).x,points.get(i).y,5,5);
client.write(points.get(i).x+" "+points.get(i).y+" "+alpha+"\n");
}
}
void mouseDragged(){
if(mouseButton==LEFT){points.add(new PVector(mouseX,mouseY));alpha=1;}
if(mouseButton==RIGHT&&points.size()>0){points.remove(points.size()-1);alpha=2;}
}
void mouseReleased(){
alpha=0;
}
import processing.net.*;
Server server;
ArrayList<PVector>points;
Client client;
void setup(){
size(800,600);
server =new Server(this,7777);
points = new ArrayList<PVector>();
}
void draw(){
background(255);
Client temp=server.available();
if(temp!=null){client = temp;}
if(client !=null){
String now=client.readString();
if(now != null){
print (now);
String[] now2 = splitTokens(now);
for(int j=0;j<now2.length;j+=3)
{
if(int(now2[j+2])==1){
for(int i=0;i<now2.length;i+=3){
points.add(new PVector(int(now2[i+0]),int(now2[i+1])));
}
}
if(int(now2[j+2])==2&&points.size()>0){
for(int i=0;i<now2.length;i+=3){
points.remove(points.size()-1);
}
}
if(int(now2[j+2])==0){
for(int i=0;i<points.size();i+=3)
{
ellipse(points.get(i).x,points.get(i).y,5,5);
}
}
}
/*line(float(now2[0]),float(now2[1]),float(now2[2]),float(now2[3]));*/
}
}
}

沒有留言:
張貼留言