How to Management a Servo Engine With Device Studying and openFrameworks

 #include "ofApp.h"
#include "ofxOsc.h" //--------------------------------------------------------------
void ofApp::setup(){ emailer.setup(HOST, SENDPORT); recipient.setup(RECEIVEPORT); ofSetFrameRate(60); sequential.listDevices(); vector <ofSerialDeviceInfo> deviceList = sequential.getDeviceList(); // this should be set to whatever com slot your sequential system is linked with. // (ie, COM4 on a pc, /dev/tty.... on a linux systemunix, /dev/tty... on a mac) // arduino customers sign in arduino app.... int baud = 9600; sequential.setup(0, baud); //open the first system // ms windows example //serial.setup("COM10", baud); // mac osx example //serial.setup("/dev/tty.usbserial-A4001JEC", baud); //linux example //serial.setup("/dev/ttyUSB0", baud); } //--------------------------------------------------------------
void ofApp::update(){ // Delivering information to the wekinator ofxOscMessage m; m.setAddress(string(SENDMESSAGE)); m.addFloatArg((float)mouseX); m.addFloatArg((float)mouseY); emailer.sendMessage(m, false); // looking for inbound information from wekinator while (receiver.hasWaitingMessages()) { ofxOscMessage msg; recipient.getNextMessage(&msg); // Get Concept if (msg.getAddress() == RECEIVEMESSAGE) { outputData = msg.getArgAsFloat(0);	// Saved it } } sequential.writeByte(outputData); // sending the information to arduino
} //--------------------------------------------------------------
void ofApp::draw(){ ofSetColor(255, 0, 0); sequence buf = "Sending message " + string(SENDMESSAGE) + " to " + string(HOST) + " on slot " + ofToString(SENDPORT); ofDrawBitmapString(buf, 10, 20); buf = "X=" + ofToString(mouseX) + ", Y=" + ofToString(mouseY); ofDrawBitmapString(buf, 10, 50); ofSetColor(0, 255, 0); ofDrawRectangle(mouseX, mouseY, boxSize, boxSize);
} //--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){ mouseX = x; mouseY = y;
} 

Post Author: Hack3rN3ws

Leave a Reply

Your email address will not be published. Required fields are marked *