Blog J.Schweiss

Infosammlung zu .NET- und anderen Programmier-Themen

Arduino IDE 1.6 features

clock April 27, 2015 02:03 by author Administrator

here

 

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}



RCSwitch mit 433 MHz und Tücken mit Leonardo-Interrupts

clock April 27, 2015 01:39 by author Administrator

Beim Herumexperimentieren mit der RCSwitch-Library hier um die Definition für FHEM zu finden.

image

NanoCUL mit CC1101, Blog, FHEMduino, CUL-Emulator, FHEM-Übersicht

image

 

ist mir bei der  Empfags-Demo aufgefallen, dass die Zeile

  if (mySwitch.available()) 

nie True wurde.

Ursache war , dass in den Beispielen immer ein Arduino UNO benutzt wurde.

Bei mir kam ein Arduino Leonardo zum Einsatz!

  mySwitch.enableReceive(1);  // Receiver on interrupt 1 on leonardo(!) (not 0 as on UNO)  => that is pin #2#

Und siehe da:

http://www.arduino.cc/en/Reference/attachInterrupt

    https://code.google.com/p/arduino/issues/detail?id=714

This is valid for Leonardo :
    Int0 on D3,
    Int1 on D2,
    Int2 on D0,
    Int3 on D1
    http://arduino.cc/en/Reference/attachInterrupt shows pin 7 as interrupt 4 for the Leonardo (one of 5 hardware interrupts).  But    http://www.atmel.com/Images/7766s.pdf shows int.6. for port-pin E-6.  And the above shows just 4 interrupts...
    Documentations needs clarifying as to what hardware interrupts the Leonardo has, on what interrupt numbers. 
   
   See  Raw-Data:
    http://test.sui.li/oszi/

 

image

Insgesamt 32 Takte mit 12 Daten.

9448,272,940,280,940,276,940,276,940,276,944,276,940,276,944,272,940,276,944,272,944,276,940,276,940,276,940,888,332,276,944,884,336,272,944,884,336,276,940,888,332,276,940,276,944,272,944,884,336,

image

Hauscode: “11111”  , scheint bei den Pollin Steckdosen invertiert zu sein, also “00000” (siehe auch  hier)

DeviceId:      01111

Hier ein Beispiel-Output. (die Raw-Data-Werte in obige Webseite pasten.)

Setup done....
Received 1361 / 24bit Protocol: 1
Decimal: 1361 (24Bit) Binary: 000000000000010101010001 Tri-State: 000000FFFF0F ¨ C
Ä ¨ PulseLength: 304 microseconds Protocol: 1
Raw data: 9448,276,944,276,940,276,940,276,940,280,936,280,936,280,940,276,940,276,944,272,940,276,944,276,936,280,940,884,336,276,936,888,332,280,940,884,332,280,940,888,328,280,940,276,940,276,940,888,332,

Here is my code for Leonardo:

 

/*
  Simple example for receiving, here as Leonardo Version
  See Interrupt for D3,D2 !
  
  http://code.google.com/p/rc-switch/

    https://code.google.com/p/arduino/issues/detail?id=714
    Int0 on D3, 
    Int1 on D2, 
    Int2 on D0, 
    Int3 on D1
    http://arduino.cc/en/Reference/attachInterrupt shows pin 7 as interrupt 4 for the Leonardo (one of 5 hardware interrupts).  
But http://www.atmel.com/Images/7766s.pdf shows int.6. for port-pin E-6.  And the above shows just 4 interrupts...
    Documentations needs clarifying as to what hardware interrupts the Leonardo has, on what interrupt numbers.  
    
    Raw-Data:
    http://test.sui.li/oszi/

*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();


int ledPin = 9;                 // LED connected to digital pin 13
int onboard_led = 13;
//------------------------------------------------------------
void blink()
{   digitalWrite(ledPin, HIGH);   // sets the LED on   delay(50); // waits for a second   digitalWrite(ledPin, LOW);    // sets the LED off   delay(50);  // waits for a second
}
//------------------------------------------------------------
void blink_system()
{   digitalWrite(onboard_led, HIGH);   // sets the LED on   delay(50); // waits for a second   digitalWrite(onboard_led, LOW);    // sets the LED off   delay(50); // waits for a second
}
//------------------------------------------------------------
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength)
{   static char bin[64];   unsigned int i=0;   while (Dec > 0)   {     bin[32+i++] = (Dec & 1 > 0) ? '1' : '0';     Dec = Dec >> 1;   }   for (unsigned int j = 0; j< bitLength; j++)   {     if (j >= bitLength - i)     {       bin[j] = bin[ 31 + i - (j - (bitLength - i)) ];     }     else     {       bin[j] = '0';     }   }   bin[bitLength] = '\0';      return bin;
}
//------------------------------------------------------------
void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) 
{   if (decimal == 0)   {     Serial.print("Unknown encoding.");   } else {     char* b = dec2binWzerofill(decimal, length);     Serial.print("Decimal: ");     Serial.print(decimal);     Serial.print(" (");     Serial.print( length );     Serial.print("Bit) Binary: ");     Serial.print( b );     Serial.print(" Tri-State: ");     Serial.print( bin2tristate( b) );     Serial.print(" PulseLength: ");     Serial.print(delay);     Serial.print(" microseconds");     Serial.print(" Protocol: ");     Serial.println(protocol);   }      Serial.print("Raw data: ");   for (int i=0; i<= length*2; i++) {     Serial.print(raw[i]);     Serial.print(",");   }   Serial.println();   Serial.println();
}

//------------------------------------------------------------
static char* bin2tristate(char* bin) {   char returnValue[50];   int pos = 0;   int pos2 = 0;   while (bin[pos]!='\0' && bin[pos+1]!='\0') {     if (bin[pos]=='0' && bin[pos+1]=='0') {       returnValue[pos2] = '0';     } else if (bin[pos]=='1' && bin[pos+1]=='1') {       returnValue[pos2] = '1';     } else if (bin[pos]=='0' && bin[pos+1]=='1') {       returnValue[pos2] = 'F';     } else {       return "not applicable";     }     pos = pos+2;     pos2++;   }   returnValue[pos2] = '\0';   return returnValue;
}
//------------------------------------------------------------
void setup() 
{   pinMode(ledPin, OUTPUT);  // sets the digital pin as output   pinMode(onboard_led, OUTPUT);   Serial.begin(9600);      while (!Serial)   {     ; // wait for serial port to connect. Needed for Leonardo only   }   Serial.println("Setup done....");      //mySwitch.setProtocol(1);   mySwitch.enableReceive(1);  // Receiver on inerrupt 1 on leonardo(!) (not 0 on UNO)  => that is pin #2#     }
//------------------------------------------------------------
void loop() 
{   digitalWrite(ledPin, LOW);   digitalWrite(onboard_led, HIGH);   if (mySwitch.available())   {  int value = mySwitch.getReceivedValue(); if (value == 0) {  Serial.print("Unknown encoding");     }      else     {       Serial.print("Received ");       Serial.print( mySwitch.getReceivedValue() );       Serial.print(" / ");       Serial.print( mySwitch.getReceivedBitlength() );       Serial.print("bit ");       Serial.print("Protocol: ");       Serial.println( mySwitch.getReceivedProtocol() );     }         output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());         mySwitch.resetAvailable();   }   else   {     int val=0;      val = digitalRead(2);      digitalWrite(ledPin, val);     //blink_system();     }
}

//------------------------------------------------------------


Soap FAQs

clock April 25, 2015 21:50 by author Administrator

here



Oracle FAQs

clock April 25, 2015 21:41 by author Administrator

here

DBA Checklist

Oracle Health



SDR mit Pi

clock April 25, 2015 03:21 by author Administrator

HowTo



Microsoft Message Analyzer

clock April 20, 2015 02:10 by author Administrator

download V1.2



u8glib

clock April 19, 2015 21:24 by author Administrator

graphic lib

ugclib for ST7735

lcd oszilloscope for  DG-16080-11 with touch screen basics

 

wifi terminal



PI Bootstrap

clock April 13, 2015 00:48 by author Administrator

here



Independent ON-OFF Times

clock April 13, 2015 00:40 by author Administrator

with millis()

How to reste millis()

 

// On and Off Times (as int, max=32secs)

const

unsigned int onTime = 1000;

const

unsigned int offTime = 500;

// Tracks the last time event fired

unsigned

long previousMillis=0;

// Interval is how long we wait

int

interval = onTime;

// Used to track if LED should be on or off

boolean LED13state

= true;

// Usual Setup Stuff

void

setup() {

pinMode

(13, OUTPUT);

}

void

loop() {
// Set Pin 13 to state of LED13state each timethrough loop() // If LED13State hasn't changed, neither will the pin

digitalWrite

(13, LED13state);
// Grab snapshot of current time, this keeps all timing // consistent, regardless of how much code is inside the next if-statement unsigned long currentMillis = millis(); // Compare to previous capture to see if enough time has passed if ((unsigned long)(currentMillis - previousMillis) >= interval) { // Change wait interval, based on current LED state if (LED13state) { // LED is currently on, set time to stay off

interval

= offTime;
} else { // LED is currently off, set time to stay on

interval

= onTime;
} // Toggle the LED's state, Fancy, eh!?

LED13state

= !(LED13state);
// Save the current time to compare "later"

previousMillis

= currentMillis;
}

}



Measure Battery Capacity

clock April 13, 2015 00:32 by author Administrator

here



F() Macro

clock April 12, 2015 23:48 by author Administrator

explained on programming

Serial.println(F(“Hello World”));
Lcd.print(F(“W”));

The F() macro tells the compiler to leave this particular array in PROGMEM. Then when it is time to access it, one byte of the data is copied to RAM at a time. There’s a small performance overhead for this extra work. However, printing strings over Serial or to a LCD is a really slow process, so a few extra clock cycles really won’t matter.

ProgMem

 

Serial: Multi Digit Integers

void

setup()

{

Serial.begin(9600);

}

void

loop() {

char buffer[] = {' ',' ',' ',' ',' ',' ',' '}; // Receive up to 7 bytes

while (!Serial.available()); // Wait for characters

Serial.readBytesUntil('n', buffer, 7);

int incomingValue = atoi(buffer);

Serial.println(incomingValue);

}

void

setup()

{

Serial.begin(9600);

}

unsigned

int integerValue=0; // Max value is 65535

char

incomingByte;

void

loop()

{

if (Serial.available() > 0) { // something came across serial

integerValue = 0; // throw away previous integerValue

while(1) { // force into a loop until 'n' is received

incomingByte = Serial.read();

if (incomingByte == '\n') break; // exit the while(1), we're done receiving

if (incomingByte == -1) continue; // if no characters are in the buffer read() returns -1

integerValue *= 10; // shift left 1 decimal place

// convert ASCII to integer, add, and shift left 1 decimal place

integerValue = ((incomingByte - 48) + integerValue);

}

Serial.println(integerValue); // Do something with the value

}

}



Powershell

clock April 12, 2015 23:19 by author Administrator

Blogger Article
Francois-Xavier Cat Standard and Advanced PowerShell functions
Mike F Robbins PowerShell Advanced Functions: Can we build them better? With parameter validation, yes we can!
Adam Bertram #PSBlogWeek – Dynamic Parameters and Parameter Validation
Jeffery Hicks PowerShell Blogging Week: Supporting WhatIf and Confirm
June Blender Advanced Help for Advanced Functions – #PSBlogWeek
Boe Prox A Look at Try/Catch in PowerShell
  http://blogs.technet.com/b/josebda/

from here



ASP.NET 5 on Ubuntu Linux

clock April 12, 2015 22:36 by author Administrator

Article



Function Pointer in C++

clock April 12, 2015 21:56 by author Administrator

Article



USB serial device by VID/PID

clock April 12, 2015 21:43 by author Administrator

here

 

Imports System
Imports System.IO
Imports System.Management
Imports Microsoft.Win32
Imports System.Text.RegularExpressions
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk1 As RegistryKey = Registry.LocalMachine  ' HKEY_LOCAL_MACHINE
        Dim rk2 As RegistryKey = rk1.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum")  ' HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
        TextBox_FileDump.AppendText(vbCrLf + "rk1 = " + rk1.ToString())
        TextBox_FileDump.AppendText(vbCrLf + "rk2 = " + rk2.ToString())
 
        Dim VID As String = "0403"
        Dim PID As String = "6001"
        Dim pattern As String = String.Format("^VID_{0}.PID_{1}", VID, PID)
        Dim _rx As Regex = New Regex(pattern, RegexOptions.IgnoreCase)
        Dim s3 As String
        For Each s3 In rk2.GetSubKeyNames()
            TextBox_FileDump.AppendText(vbCrLf + "s3 = " + s3)
 
            Dim rk3 As RegistryKey = rk2.OpenSubKey(s3)
            TextBox_FileDump.AppendText(vbCrLf + "rk3 = " + rk3.ToString())
 
            Dim s As String
            For Each s In rk3.GetSubKeyNames()
                TextBox_FileDump.AppendText(vbCrLf + "s = " + s)
 
                If _rx.Match(s).Success Then
                    Dim rk4 As RegistryKey = rk3.OpenSubKey(s)
                    TextBox_FileDump.AppendText(vbCrLf + "rk4 = " + rk4.ToString())
 
                    Dim s2 As String
                    For Each s2 In rk4.GetSubKeyNames()
                        TextBox_FileDump.AppendText(vbCrLf + "s2 = " + s2)
 
                        Dim rk5 As RegistryKey = rk4.OpenSubKey(s2)
                        Dim rk6 As RegistryKey = rk5.OpenSubKey("Device Parameters")
                        TextBox_FileDump.AppendText(vbCrLf + "rk5 = " + rk5.ToString())
                        TextBox_FileDump.AppendText(vbCrLf + "rk6 = " + rk6.ToString())
 
                        TextBox_FileDump.AppendText(vbCrLf + "PORT NAME = " + rk6.GetValue("PortName"))
 
                    Next
 
                End If
 
            Next
 
        Next
 

    End Sub



LIRC on Raspi

clock April 12, 2015 20:55 by author Administrator

Article



WinToFlash

clock April 11, 2015 19:16 by author Administrator

here



USB printer go wireless

clock April 11, 2015 19:12 by author Administrator

HowTo with TP-LINNK WR-703N



SDR

clock April 11, 2015 19:06 by author Administrator

Article

Devices

Quick Start

Gnu Radio



Wireless Printer

clock April 11, 2015 18:57 by author Administrator

Article with TP-Link Router

Unbrick FTDI