Skip to content

Instantly share code, notes, and snippets.

@danimtzc
danimtzc / arduino
Created May 22, 2012 10:35
arduino codigo final
char variable;
boolean estado;
void setup() {
Serial.begin(115200);
estado=false;
//////////////////////////////////////////////
//ADELANTE
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
public class HolaMundo extends MIDlet {
// Componentes del interfaz de usuario
private Display display;
private Form form;
//Constructor de la clase.
public HolaMundo() {
// Cogemos el display
display=Display.getDisplay(this);
public class HolaMundo extends Activity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
TextView tv = new TextView(this);
tv.setText("Hola Mundo");
setContentView(tv);
}
}
@Override
protected void finalize(){
_wifiLock.release();
}
for(Iterator<ScanResult> it = scanResults.iterator(); it.hasNext();){
ScanResult result = it.next();
if (_ssidsMap.containsKey(result.SSID)){
// Si ya existe informacion sobre el SSID, la actualiza.
_ssidsMap.put(result.SSID, _ssidsMap.get(result.SSID) + result.level);
} else {
// Si no existe informacion sobre el SSID, la crea.
_ssidsMap.put(result.SSID, result.level);
}
}
private final BroadcastReceiver _bcReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent){
String action = intent.getAction();
if(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)){
Log.i(WifiService.NAME, "Scan finished with " +
_wifiManager.getScanResults().size() + " items found");
calculateRSSI(_wifiManager.getScanResults());
_isScanning = false;
public void startScanning(){
Log.i(WifiService.NAME, "in startScanning()");
if (!_wifiManager.isWifiEnabled()){
Log.i(WifiService.NAME, "WIFI disabled");
Toast.makeText(_context, "Wifi Deshabilitada\nHabilitela e intente de nuevo",
Toast.LENGTH_LONG).show();
// Es aconsejable asegurarse de que se detienen los escaneos.
_scanning = false;
return;
}
<manifest nuestraAplicacion>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
...... Otras clausulas
</manifest>
public ConnectThread(BluetoothDevice device) {
mmDevice = device;
BluetoothSocket tmp = null;
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, "create() failed", e);
public AcceptThread() {
BluetoothServerSocket tmp = null;
// Create a new listening server socket
try {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID);
} catch (IOException e) {
Log.e(TAG, "listen() failed", e);
}
mmServerSocket = tmp;